u64be static method

Uint8List u64be(
  1. BigInt value
)

Encodes an unsigned 64-bit BigInt as big-endian 8 bytes.

HINT: Use when working with BigInt window values directly.

Implementation

static Uint8List u64be(BigInt value) {
  if (value.isNegative) {
    throw ArgumentError.value(value, 'value', 'Must be non-negative.');
  }
  // Mask to 64 bits (logical constraint).
  final mask64 = (BigInt.one << 64) - BigInt.one;
  final v = value & mask64;

  final out = Uint8List(8);
  var tmp = v;
  for (var i = 7; i >= 0; i--) {
    out[i] = (tmp & BigInt.from(0xff)).toInt();
    tmp = tmp >> 8;
  }
  return out;
}