readBigInt method

BigInt readBigInt(
  1. int number, {
  2. Endianness endianness = Endianness.Big,
})

Implementation

BigInt readBigInt(int number, {Endianness endianness = Endianness.Big}) {
  Uint8List d = readBytes(number);
  BigInt value = BigInt.from(0);
  if (endianness == Endianness.Big) {
    for (var n = 0; n < d.length; n++) {
      value <<= 256;
      value += BigInt.from(d[d.length - n - 1]);
    }
  } else if (endianness == Endianness.Little) {
    for (var n = d.length - 1; n >= 0; n--) {
      value <<= 256;
      value += BigInt.from(d[d.length - n - 1]);
    }
  }
  return value;
}