removeLast method Null safety

  1. @override
T removeLast()

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]


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;