toBigEndianBytes function
Derive bytearray from num where the bytearray is not padded with 0.
Implementation
Uint8List toBigEndianBytes(BigInt num, int width) {
Uint8List bytes = toPaddedBigEndianBytes(num, width);
int firstNonZeroIndex = findFirstNonZeroIndex(bytes);
if (firstNonZeroIndex == -1) {
return Uint8List.fromList([0]);
}
return bytes.sublist(firstNonZeroIndex);
}