hexFromArgb function
Converts an ARGB integer to a 6-character RGB hex string.
Note: The alpha channel is discarded. This function always returns
a 6-character hex code (e.g., #FF5733), which is the standard format
for CSS colors and does not support transparency. If you need to preserve
alpha, use an 8-character ARGB hex format instead.
Returns a hex string with or without a leading # based on leadingHashSign.
Implementation
String hexFromArgb(int argb, {bool leadingHashSign = true}) {
final red = redFromArgb(argb);
final green = greenFromArgb(argb);
final blue = blueFromArgb(argb);
return '${leadingHashSign ? '#' : ''}'
'${red.toRadixString(16).padLeft(2, '0').toUpperCase()}'
'${green.toRadixString(16).padLeft(2, '0').toUpperCase()}'
'${blue.toRadixString(16).padLeft(2, '0').toUpperCase()}';
}