startFrom method
Pull from the OffsetIterator from the specified offset.
Implementation
OffsetIterator<T> startFrom(
int? offset, {
String name = 'startFrom',
bool? cancelOnError,
bool bubbleCancellation = true,
}) {
final parent = this;
return OffsetIterator(
name: toStringWithChild(name),
init: () => offset ?? parent.offset,
process: (offset) {
final earliest = parent.earliestAvailableOffset - 1;
if (offset < earliest) offset = earliest;
final futureOr = parent.pull(offset);
if (futureOr is Future<Option<T>>) {
return futureOr.then((item) => OffsetIteratorState(
acc: offset + 1,
chunk: item is Some ? [(item as Some).value] : null,
hasMore: parent.hasMore(offset + 1),
));
}
return OffsetIteratorState(
acc: offset + 1,
chunk: futureOr is Some ? [(futureOr as Some).value] : null,
hasMore: parent.hasMore(offset + 1),
);
},
cleanup: parent.generateCleanup(bubbleCancellation: bubbleCancellation),
cancelOnError: cancelOnError ?? parent.cancelOnError,
seed: parent.generateSeed(startOffset: offset),
);
}