encodeBigInt function

Bytes encodeBigInt(
  1. BigInt value
)

Implementation

Bytes encodeBigInt(BigInt value) {
  if (value == BigInt.zero) {
    return Bytes([]);
  }
  final length = (value.bitLength + 8) >> 3;
  var bytes = bigIntToBytes(value, length, Endian.big, signed: true);
  while (bytes.length > 1 && bytes[0] == ((bytes[1] & 0x80) != 0 ? 0xFF : 0)) {
    bytes = bytes.sublist(1);
  }
  return bytes;
}