write method
Implementation
Uint8List write() {
BigInt value = val is BigInt ? val : BigInt.from(val);
String buff = value.toRadixString(16);
if (buff.length > 2 * bytelen) {
throw Exception('Out of Bounds!');
}
buff = buff.padLeft(2 * bytelen, '0');
Uint8List buffer = Uint8List.fromList(List<int>.generate(buff.length ~/ 2,
(i) => int.parse(buff.substring(2 * i, 2 * i + 2), radix: 16)));
// Remove leading zero bytes
int wasteBytes = 0;
for (int i = 0; i < buffer.length; i++) {
if (buffer[i] == 0) {
wasteBytes++;
} else {
break;
}
}
return buffer.sublist(wasteBytes);
}