popFront method

void popFront()

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

Implementation

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