toHex method

String toHex({
  1. int width = 0,
})

Converts this BigInt to a HEX string.

  • width of the HEX string. Will left-pad with zeroes if needed.

Implementation

String toHex({int width = 0}) {
  var hex = toRadixString(16).toUpperCase();
  if (width > 0) {
    if (isNegative) {
      hex = hex.substring(1);
      return '-${hex.padLeft(width, '0')}';
    } else {
      return hex.padLeft(width, '0');
    }
  }
  return hex;
}