formatWithMap method

String formatWithMap(
  1. Map<String, String> mappedValues
)

Implementation

String formatWithMap(Map<String, String> mappedValues) {
  return replaceAllMapped(RegExp(r'{(.*?)}'), (match) {
    final mapped = mappedValues[match[1]];
    if (mapped == null) {
      throw ArgumentError(
          '$mappedValues does not contain the key "${match[1]}"');
    }
    return mapped;
  });
}