captureVars function

VarsCap captureVars(
  1. String str
)

Implementation

VarsCap captureVars(String str) {
  var out = <String, String>{};
  if (_matchParamsRegExp2.hasMatch(str)) {
    final wordset = <String>{};
    final matches = _matchParamsRegExp2.allMatches(str);
    for (var match in matches) {
      wordset.add(str.substring(match.start, match.end));
    }
    // Replacing
    var words = wordset.toList();
    for (var i = 0; i < words.length; i++) {
      var key = '$i';
      var value = words[i];
      var innerKey = value.substring(2, value.length - 2);
      innerKey = innerKey.replaceAll('"', '\\"');
      out[key] = innerKey;
      // trace('damn var is:: ${out[key]}');
      str = str.replaceAll(value, '{{$key}}');
    }
  }
  return VarsCap(str, out);
}