colorToHex function
Prefixes a hash sign if leadingHashSign
is set to true
(default is true
).
Implementation
String? colorToHex(Color? color, {bool leadingHashSign = true}) {
if (color == null) return null;
return '${leadingHashSign ? '#' : ''}'
'${color.alpha.toRadixString(16)}'
'${color.red.toRadixString(16)}'
'${color.green.toRadixString(16)}'
'${color.blue.toRadixString(16)}';
}