peek method

E? peek()

Retrieves, but does not remove, the head of this queue.

Returns null if this queue is empty.

Example:

final queue = Queue<int>();
queue.offer(100);
print(queue.peek()); // 100
print(queue.length); // 1 (element still in queue)

Implementation

E? peek() {
  if (_elements.isEmpty) {
    return null;
  }
  return _elements.first;
}