toHex method
Converts this color to a hex string (e.g. "#RRGGBB" or "#AARRGGBB").
Implementation
String toHex({bool leadingHashSign = true, bool includeAlpha = false}) {
final prefix = leadingHashSign ? '#' : '';
final aHex = (a * 255).round().toRadixString(16).padLeft(2, '0');
final rHex = (r * 255).round().toRadixString(16).padLeft(2, '0');
final gHex = (g * 255).round().toRadixString(16).padLeft(2, '0');
final bHex = (b * 255).round().toRadixString(16).padLeft(2, '0');
return '$prefix${includeAlpha ? aHex : ''}$rHex$gHex$bHex';
}