setAsObject method

void setAsObject(
  1. dynamic index,
  2. dynamic value
)

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

  • index (optional) an index of the element to set
  • value a new element or array value.

See ArrayConverter.toArray

Implementation

void setAsObject(dynamic index, dynamic value) {
  if (value == null) {
    clear();
    var elements = ArrayConverter.toArray(index);
    append(elements);
  } else {
    _values[index] = value;
  }
}