color_utils library

Extensions

ColorExtension on Color
Extension methods for Color to provide utility functions like darkening.

Functions

getContrastingTextColor(Color backgroundColor) Color
Calculates a contrasting text color (black or white) for a given background color. This is used to ensure text is readable on a colored background.
parseColorHex(String? hexString, Color defaultColor) Color
Parses a hexadecimal color string into a Color object. Supports 3-digit and 6-digit hex codes, with or without a leading '#'. Returns defaultColor if parsing fails or the string is null/empty.