readUnsignedLong method

Future<int> readUnsignedLong()

Reads and returns an 8-byte integer, converted to a Dart int according to the semantics of ByteData.getUint64 using the current endian setting.

NOTE: Dart doesn't support unsigned longs, but you can get an unsigned BigInt using BigInt.toUnsigned.

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

Implementation

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