bigIntToBytes function

Uint8List bigIntToBytes(
  1. BigInt number
)

Implementation

Uint8List bigIntToBytes(BigInt number) {
  int bytes = (number.bitLength + 7) >> 3;
  var b256 = BigInt.from(256);
  var result = Uint8List(bytes);
  for (int i = 0; i < bytes; i++) {
    result[i] = number.remainder(b256).toInt();
    number = number >> 8;
  }
  return result;
}