replaceWrappedWithMap method

String replaceWrappedWithMap({
  1. required Map<String, dynamic> values,
  2. required String openWrapChar,
  3. String? closeWrapChar,
})

Replaces the placeholders in the String with the values from the provided values map. The placeholders are Map keys surrounded by openWrapChar and closeWrapChar.

Implementation

String replaceWrappedWithMap({required Map<String, dynamic> values, required String openWrapChar, String? closeWrapChar}) {
  if (isBlank) return blankIfNull;

  string text = this;
  values.forEach((key, value) {
    String wrappedKey = key.wrap(openWrapChar, closeWrapChar);
    text = text.replaceAll(wrappedKey, value?.toString() ?? "");
  });
  return text;
}