removeFirst method

T? removeFirst()

Removes and returns the first node data from this list. This method returns null if the list is empty.

Implementation

T? removeFirst() {
  if (isEmpty) return null;
  T? removedData = _head!.data;
  _head = _head!.next;
  _head!.previous = null;
  _size--;
  return removedData;
}