popBack method

void popBack()

Removes the last element from the list. O(1). Throws a StateError if the list is empty.

Implementation

void popBack() {
  if (_tail == null) {
    throw StateError('Cannot pop from an empty SList');
  }
  _tail = _tail!.prev;
  if (_tail != null) {
    _tail!.next = null;
  } else {
    _head = null;
  }
  _length--;
}