toBytes method
Serializes this BigInt to bytes (Uint8List). The serialized data is prefixed with the size of the bytes that contains the big-integer.
Implementation
Uint8List toBytes() {
if (bitLength > 32) {
var latin1 = toString().encodeLatin1Bytes();
var bs = Uint8List(4 + latin1.length);
var byteData = bs.asByteData();
byteData.setInt32(0, -latin1.length);
bs.setAll(4, latin1);
return bs;
} else {
var bs = Uint8List(1 + 4);
bs[0] = 0;
bs.asByteData().setInt32(1, toInt());
return bs;
}
}