readBigIntSigned function
Reads a signed BigInt value from bytes starting at offset,
using size bytes in the given endian byte order.
Uses two's complement representation.
Implementation
BigInt readBigIntSigned(Uint8List bytes, int offset, int size, Endian endian) {
final unsigned = readBigIntUnsigned(bytes, offset, size, endian);
final maxPositive = BigInt.one << (size * 8 - 1);
if (unsigned >= maxPositive) {
return unsigned - (BigInt.one << (size * 8));
}
return unsigned;
}