toHexUnsigned method
Same as toHex, but will ensure that the HEX string is unsigned, converting the HEX bits to a signed integer, like a Uint32.
Implementation
String toHexUnsigned({int width = 0}) {
if (isNegative) {
var hex = toHex();
if (hex.startsWith('-')) {
hex = hex.substring(1);
}
if (hex.length % 2 != 0) {
hex = '0$hex';
}
var bs = hex.decodeHex();
var bs2 = Uint8List.fromList(bs.map((e) => 256 - e).toList());
var hex2 = bs2.toHex();
if (width > 0) {
hex2 = hex2.padLeft(width, 'F');
}
return hex2;
} else {
var hex = toHex();
if (width > 0) {
hex = hex.padLeft(width, '0');
}
return hex;
}
}