removeAt method Null safety

T removeAt(
  1. int index,
  2. {bool notifyChanges = true}
)

Removes the object at position index from the list.

This method reduces the length of this by one and moves all later objects down by one position.

Returns the removed value.

The index must be in the range 0 ≤ index < length. The list must be growable.

final parts = <String>['head', 'shoulder', 'knees', 'toes'];
final retVal = parts.removeAt(2); // knees
print(parts); // [head, shoulder, toes]

Implementation

T removeAt(int index, {bool notifyChanges = true}) {
  final removedValue = _value.removeAt(index);

  if (notifyChanges) {
    _viewModel
        .notifyChanges([EmpireStateChanged.removedFromList(removedValue)]);
  }

  return removedValue;
}