readBigInt method

MapEntry<int, BigInt> readBigInt([
  1. int offset = 0
])

Reads a BigInt at offset. See BigIntExtension.toBytes for encoding description.

Implementation

MapEntry<int, BigInt> readBigInt([int offset = 0]) {
  var byteData = asByteData();
  if (this[offset] == 0) {
    var n = byteData.getInt32(offset + 1);
    var bigInt = BigInt.from(n);
    return MapEntry(1 + 4, bigInt);
  } else {
    var sz = -byteData.getInt32(offset);
    var bs = readBytes(offset + 4, sz);
    var s = dart_convert.latin1.decode(bs);
    var bigInt = BigInt.parse(s);
    return MapEntry(4 + bs.length, bigInt);
  }
}