peekByte method

  1. @override
Future<int> peekByte()
override

Returns the next byte in the stream without advancing the position. Returns -1 if the end of the stream has been reached.

Implementation

@override
Future<int> peekByte() async {
  final current = await position;
  if (current == await length) {
    return -1;
  }

  final byte = await readByte();
  await seek(current);
  return byte;
}