formatMap method

String formatMap(
  1. Map<String, Object> args
)

Format a string.

Implementation

String formatMap(Map<String, Object> args) {
  if (this == null) {
    throw ArgumentError('string: $this');
  }
  return this!.replaceAllMapped(RegExp(r'\{(\w+)\}'), (match) {
    final key = match.group(1)!;
    if (!args.containsKey(key)) {
      throw ArgumentError('key: $key');
    }
    return args[key]!.toString();
  });
}