intToBytes function

Uint8List intToBytes(
  1. BigInt i
)

Implementation

Uint8List intToBytes(BigInt i) {
  List<int> buf = [];

  while (i >= BigInt.from(256)) {
    buf.add((i % BigInt.from(256)).toInt());
    i -= BigInt.from(256);
    i = i ~/ BigInt.from(256);
  }

  buf.add((i % BigInt.from(256)).toInt());

  return Uint8List.fromList(buf);
}