removeFirst method

T removeFirst()

Removes and returns the oldest element from the buffer.

Implementation

T removeFirst() {
  if (isEmpty) {
    throw StateError('Cannot remove from an empty RingBuffer');
  }
  final value = _buffer[_head] as T;
  _buffer[_head] = null;
  _head = (_head + 1) % _capacity;
  _isFull = false;
  return value;
}