fromTuplesArray static method

AnyValueMap fromTuplesArray(
  1. List? tuples
)

Creates a new AnyValueMap from a list of key-value pairs called tuples. The method is similar to fromTuples but tuples are passed as array instead of parameters.

  • tuples a list of values where odd elements are keys and the following even elements are values Returns a newly created AnyValueArray.

Implementation

static AnyValueMap fromTuplesArray(List? tuples) {
  var result = AnyValueMap();
  if (tuples == null || tuples.isEmpty) return result;

  for (var index = 0; index < tuples.length; index += 2) {
    if (index + 1 >= tuples.length) break;

    var name = StringConverter.toNullableString(tuples[index]);
    var value = tuples[index + 1];

    result.setAsObject(name, value);
  }

  return result;
}