intToHex static method

String intToHex(
  1. int i
)

Converts the given integer i to a hex string with a leading #.

Note that only the RGB values will be returned (like #RRGGBB), so and alpha/opacity value will be stripped.

Implementation

static String intToHex(int i) {
  assert(i >= 0 && i <= 0xFFFFFFFF);
  return '#${(i & 0xFFFFFF | 0x1000000).toRadixString(16).substring(1).toUpperCase()}';
}