nextRawBytes method

Uint8List nextRawBytes(
  1. int length
)

Extract a sequence of bytes from the range.

The length number of bytes are copied from the beginning of the range and returned. Those bytes are then no longer a part of the range.

Throws a BadEncoding if there are less than length bytes in the range, or the length is negative.

Implementation

Uint8List nextRawBytes(int length) {
  if (length < 0) {
    throw KeyBad('length is negative');
  }
  if (_end < _begin + length) {
    throw KeyBad('data incomplete (for $length bytes)');
  }

  final result = _bytes.sublist(_begin, _begin + length);

  _begin += length;

  return result;
}