removeLast method

  1. @override
T removeLast()
override

Removes and returns the newest element from the buffer without changing capacity.

Implementation

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