encodeBigInt function

Uint8List encodeBigInt(
  1. BigInt number
)

Encode a big integer into a Uint8List (8 bytes) @param {Number} number Number to encode

Implementation

Uint8List encodeBigInt(BigInt number) {
  final ByteData data = ByteData(8);
  BigInt _bigInt = number;
  for (int i = 1; i <= data.lengthInBytes; i++) {
    data.setUint8(data.lengthInBytes - i, _bigInt.toUnsigned(8).toInt());
    _bigInt = _bigInt >> 8;
  }
  return data.buffer.asUint8List();
}