peek method

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

Read the next byte without consuming it.

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

Implementation

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