removeLast method

  1. @override
T removeLast()
override

Removes and returns the last object in this list.

The list must be growable and non-empty.

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

Implementation

@override
T removeLast() {
  late T value;

  _context.conditionallyRunInAction(() {
    value = _list.removeLast();
    // Index is _list.length as it points to the index before the last element is removed
    _notifyElementUpdate(_list.length, null, value,
        type: OperationType.remove);
  }, _atom);

  return value;
}