replaceArgsOf function

String replaceArgsOf(
  1. String data,
  2. Map<String, Object?> args
)
  • replace args of map
  • in your assets the arg must starts with : to be identified as variable
  • to replace it

Implementation

String replaceArgsOf(String data, Map<String, Object?> args) {
  var msg = data;
  for (final entry in args.entries) {
    if (entry.value != null) {
      msg = msg.replaceFirst(':${entry.key}', entry.value.toString());
    }
  }
  return msg;
}