nextUint32 method Null safety

int nextUint32 ()

Extracts a big-endian 32-bit unsigned integer from the range.

Returns the value represented by the first four bytes of the range and removes those four bytes from the range.

Throws a BadEncoding if there are insufficient bytes in the range.

Implementation

int nextUint32() {
  if (end < begin + 4) {
    // Less than 4 bytes left: not enough for a 32-bit value
    throw KeyBad('data incomplete');
  }

  final a = Uint8List.fromList(
      [bytes[begin + 3], bytes[begin + 2], bytes[begin + 1], bytes[begin]]);
  final value = a.buffer.asUint32List().first;

  begin += 4;

  return value;
}