readUnsignedInt method

Future<int> readUnsignedInt()

Reads and returns a 4-byte unsigned integer decoded with the current endian setting.

Throws EOFException if EOF is reached before the needed bytes are read.

Implementation

Future<int> readUnsignedInt() async {
  await _ensureNext();
  if (_curr!.length - _pos < 4) {
    // If we're on a buffer boundary
    // Keep it simple
    return (await readByteDataImmutable(4)).getUint32(0, endian);
  } else {
    final result = _curr!.buffer
        .asByteData()
        .getUint32(_pos + _curr!.offsetInBytes, endian);
    _pos += 4;
    return result;
  }
}