replacePlaceholders function Null safety

String replacePlaceholders(
  1. String input,
  2. Map<String, String> variables,
  3. RegExp rexprVariable

Replaces placeholders in a string with values stored in a map. input: the input string [variables: a map containing (placeholder, value) pairs rexprVariable a regular expression for one variable. The variable name must be in group(1) returns: the input string with the replaced placeholders


String replacePlaceholders(
    String input, Map<String, String> variables, RegExp rexprVariable) {
  var rc = input;
  for (var matcher in rexprVariable.allMatches(input)) {
    final name =;
    if (!variables.containsKey(name)) {
          'replaceVariables(): unknown placeholder $name in ${limitString(input, 40)}');
    } else {
      rc = rc.replaceAll(!, variables[name]!);
  return rc;