core/colour/colour_helpers library
Helper functions for colours: picking readable text colours, converting between HSV and HSL, and converting to and from hex strings.
Constants
- kCompleteValidHexPattern → const String
-
Matches a complete hex colour: an optional
#followed by exactly 3, 6 or 8 hex digits (RGB,RRGGBBorAARRGGBB). - kValidHexPattern → const String
-
Matches the start of a hex colour while it's being typed: an optional
#followed by one to eight hex digits.
Functions
-
colorFromHex(
String inputString, {bool enableAlpha = true}) → Color? -
Parses a hex string such as
#F80,FF8800or#80FF8800into a Color. -
colorToHex(
Color color, {bool includeHashSign = false, bool enableAlpha = true, bool toUpperCase = true}) → String -
Formats
coloras a hex string. -
hslToHsv(
HSLColor color) → HSVColour - Converts an HSL (hue, saturation, lightness) colour to HSV (hue, saturation, value).
-
hsvToHsl(
HSVColor color) → HSLColour - Converts an HSV (hue, saturation, value) colour to HSL (hue, saturation, lightness).
-
useWhiteForeground(
Color backgroundColor, {double bias = 0.0}) → bool -
Whether white text is easier to read than black text on
backgroundColor.