readBytes method

  1. @override
UnmodifiableUint8ListView 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
UnmodifiableUint8ListView readBytes(int length) {
  if ((offset + length) > _buffer.length) {
    throw Exception('Not enough bytes to read');
  }
  final bytes =
      UnmodifiableUint8ListView(_buffer.buffer.asUint8List(offset, length));
  offset += length;
  return bytes;
}