parametersToMap method

Map<String, dynamic> parametersToMap()

Return all parameters as a Map with of parameters names and values.

See positionalParametersNames.

Implementation

Map<String, dynamic> parametersToMap() {
  var map = <String, dynamic>{...?namedParameters};

  var positionalParametersNames =
      this.positionalParametersNames ?? <String>[];

  for (var i = 0; i < normalParameters.length; ++i) {
    var val = normalParameters[i];
    var name = i < positionalParametersNames.length
        ? positionalParametersNames[i]
        : 'arg_$i';
    map[name] = val;
  }

  var optionalParameters = this.optionalParameters;
  if (optionalParameters != null) {
    var pIdxOffset = normalParameters.length;

    for (var i = 0; i < optionalParameters.length; ++i) {
      var val = optionalParameters[i];
      var pIdx = pIdxOffset + i;
      var name = pIdx < positionalParametersNames.length
          ? positionalParametersNames[pIdx]
          : 'arg_$pIdx';
      map[name] = val;
    }
  }

  return map;
}