tryPull method

T? tryPull()

Non-blocking pull: returns the next buffered item, or null if the buffer is empty. NOTE: with a nullable T a buffered null is indistinguishable from "empty" here — use pull when T is nullable. Audited: 2026-06-12 11:26 EDT

Implementation

T? tryPull() {
  if (_buffer.isEmpty) {
    return null;
  }
  final T item = _buffer.removeFirst();
  _admitWaitingProducer();
  return item;
}