setAsObject method

void setAsObject(
  1. dynamic key, [
  2. dynamic value
])

Sets a new value to map element specified by its index. When the index is not defined, it resets the entire map value. This method has double purpose because method overrides are not supported in JavaScript.

  • key (optional) a key of the element to set
  • value a new element or map value.

See MapConverter.toMap

Implementation

void setAsObject(key, [value]) {
  if (value == null) {
    clear();
    var values = MapConverter.toMap(key);
    append(values);
  } else {
    var keyObj = StringConverter.toNullableString(key);
    if (keyObj != null) {
      _values[keyObj] = StringConverter.toNullableString(value);
    }
  }
}