pull method

FutureOr<Option<T>> pull([
  1. int? currentOffset
])

Pull the next item. If currentOffset is not provided, it will use the latest head offset.

Implementation

FutureOr<Option<T>> pull([int? currentOffset]) {
  final offset = currentOffset ?? _offset;
  if (offset < 0 || offset > _offset) {
    throw RangeError.range(offset, 0, _offset, 'currentOffset');
  }

  if (_status.index < OffsetIteratorStatus.active.index) {
    _maybeSeedValue();

    if (_init == null) return _handleInit(offset, null);

    final initResult = _init!();
    return initResult is Future
        ? initResult.then((r) => _handleInit(offset, r))
        : _handleInit(offset, initResult);
  }

  return _handleOffsetRequest(offset);
}