readBytes method

  1. @override
Uint8List readBytes(
  1. int length
)
override

Get the bytes from the current index to the length

Example:

final input = Input.fromHex('0x010203');
print(input.readBytes(3)); // [1, 2, 3]

Implementation

@override
Uint8List readBytes(int length) {
  if ((offset + length) > _buffer.length) {
    throw Exception('Not enough bytes to read');
  }
  final bytes =
      _buffer.buffer.asUint8List(offset, length).asUnmodifiableView();
  offset += length;
  return bytes;
}