next method

int next({
  1. int onEnd()?,
})

Read and return the next byte. The readCount will be incremented by 1.

If there are no unreadCount left, then evaluate the optional onEnd function and return the result. If no function is provided, then return -1.

Implementation

int next({int Function()? onEnd}) {
  if (atEnd() == false) return basicNext();
  return onEnd?.call() ?? -1;
}