bigIntToBytes static method

Uint8List bigIntToBytes(
  1. BigInt number
)

LITTLE ENDIAN!!

Implementation

static Uint8List bigIntToBytes(BigInt number) {
  // Not handling negative numbers. Decide how you want to do that.
  int bytes = (number.bitLength + 7) >> 3;
  var b256 = new BigInt.from(256);
  var result = new Uint8List(bytes);
  for (int i = 0; i < bytes; i++) {
    result[i] = number.remainder(b256).toInt();
    number = number >> 8;
  }
  return result;
}