CircularBuffer<T>.create constructor

CircularBuffer<T>.create(
  1. int capacity,
  2. T empty
)

Create a circular buffer with capacity slots, where empty is a default value that can fill unused slots in an underlying container.

Example usage, nullable type:

final buf = CircularBuffer<MyThing?>.create(10, null)

Example usage, non-nullable type:

final buf = CircularBuffer.create(10, '')

Implementation

CircularBuffer.create(int capacity, T empty)
    : _store = List.filled(capacity, empty);