format method

String format(
  1. Map<String, String> args
)

Formats the strings.

Replaces {placeholder} in strings with { "placeholder" : "some value"} map. Example print("Hello {user}! You have {count} new messages.".format({ "user" : "John", "count" : "10"})) prints -> "Hello John! You have 10 new messages."

Implementation

String format(Map<String, String> args) {
  String test = this;
  for (final MapEntry<String, String> entry in args.entries) {
    test = test.replaceAll('{${entry.key}}', entry.value);
  }
  return test;
}