operator []= method Null safety

  1. @override
void operator []=(
  1. int index,
  2. EntityT element
)
override

Sets the value at the given index in the list to value.

The index must be a valid index of this list, which means that index must be non-negative and less than length.

Implementation

@override
void operator []=(int index, EntityT element) {
  final items = _items;
  if (0 > index || index >= items.length) {
    throw RangeError.index(index, this);
  }
  if (index < items.length) {
    if (items[index] == element) return;
    _track(items[index], -1);
  }
  items[index] = element;
  _track(element, 1);
}