toHex method

String toHex({
  1. bool withAlpha = true,
})

Returns a HEX string value of this color.

Implementation

String toHex({bool withAlpha = true}) =>
    '#'
    '${(withAlpha ? (a * 255).round().toRadixString(16).toUpperCase().padLeft(2, '0') : '')}'
    '${(r * 255).round().toRadixString(16).toUpperCase().padLeft(2, '0')}'
    '${(g * 255).round().toRadixString(16).toUpperCase().padLeft(2, '0')}'
    '${(b * 255).round().toRadixString(16).toUpperCase().padLeft(2, '0')}';