toHex method

String toHex()

Implementation

String toHex() {
  String c(double v) =>
      (v * 255).round().clamp(0, 255).toRadixString(16).padLeft(2, '0');
  return '#${c(r)}${c(g)}${c(b)}${a == 1 ? '' : c(a)}'.toUpperCase();
}