toShortHex method

String toShortHex()

Convert to Hex String Trim extra zeroes in the beginning of a string. Returns Hex String without leading zeroes.

Example:

[0,1,2,3,4].toShortHex(); // "0x1020304"

Implementation

String toShortHex() {
  final trimmed =
      toHex().replaceFirst(RegExp('^0x0*', caseSensitive: false), '');
  return '0x$trimmed';
}