writeUint64 method

void writeUint64(
  1. int value, [
  2. Endian endian = .big
])

Writes a 64-bit unsigned integer.

Note: Since Dart's int type is a signed 64-bit integer, this method is limited to the range 0 to 2^63 - 1 (9,223,372,036,854,775,807). Values above this cannot be represented as positive integers in Dart.

On web targets, precision is further limited to 2^53.

endian specifies byte order (defaults to big-endian).

Example:

writer.writeUint64(9007199254740991);  // Max safe JS int

Throws RangeError if value is outside the valid range.

Implementation

@pragma('vm:prefer-inline')
@pragma('dart2js:tryInline')
void writeUint64(int value, [Endian endian = .big]) {
  _checkRange(value, 0, kMaxInt64, 'Uint64');

  _ws.ensureEightBytes();
  _ws.data.setUint64(_ws.offset, value, endian);
  _ws.offset += 8;
}