encodeConditionValue static method

String encodeConditionValue(
  1. dynamic o
)

Implementation

static String encodeConditionValue(dynamic o) {
  var s = Json.encode(o, toEncodable: toJsonEncodable);

  s = s.replaceAllMapped(_conditionParameterRegExp, (m) {
    var groupIdx = m.group(1);
    if (groupIdx != null) {
      var idxStr = groupIdx.substring(1);
      var idx = idxStr.isNotEmpty ? int.parse(idxStr) : -1;
      return idx >= 0 ? '?#$idx' : '?#';
    }

    var groupKey = m.group(2);
    if (groupKey != null) {
      var key = groupKey.substring(1);
      return groupKey.isNotEmpty ? '?:$key' : '?:';
    }

    return '?';
  });

  return s;
}