ColorUtils extension
Extensions on Color for real-world utility operations.
- on
Properties
- complementary → Color
-
Available on Color, provided by the ColorUtils extension
Returns the complementary color (180° hue rotation).no setter - contrastColor → Color
-
Available on Color, provided by the ColorUtils extension
Returns black or white — whichever has better contrast against this color. Useful for choosing text color on a colored background.no setter - grayscale → Color
-
Available on Color, provided by the ColorUtils extension
Returns a desaturated (grayscale) version of this color.no setter - isDark → bool
-
Available on Color, provided by the ColorUtils extension
Returnstrueif this color is perceived as dark.no setter - isLight → bool
-
Available on Color, provided by the ColorUtils extension
Returnstrueif this color is perceived as light. Uses the WCAG relative luminance formula.no setter - luminance → double
-
Available on Color, provided by the ColorUtils extension
Returns the WCAG relative luminance of this color (0..1).no setter -
splitComplementary
→ List<
Color> -
Available on Color, provided by the ColorUtils extension
Returns the two split-complementary colors (150° and 210° from this hue).no setter -
tetradic
→ List<
Color> -
Available on Color, provided by the ColorUtils extension
Returns the four colors of a tetradic (square) color scheme.no setter -
triadic
→ List<
Color> -
Available on Color, provided by the ColorUtils extension
Returns the three colors of a triadic color scheme.no setter
Methods
-
analogous(
{int count = 3, double angle = 30}) → List< Color> -
Available on Color, provided by the ColorUtils extension
Returnscountanalogous colors spacedangledegrees apart on the color wheel, centered on this color. -
contrastRatio(
Color other) → double -
Available on Color, provided by the ColorUtils extension
Returns the WCAG contrast ratio between this color andother(1–21). -
darken(
double amount) → Color -
Available on Color, provided by the ColorUtils extension
Darkens this color byamount(0..1) in HSL space. -
isAccessibleOn(
Color background, {double minRatio = 4.5}) → bool -
Available on Color, provided by the ColorUtils extension
Returnstrueif this color has sufficient contrast againstbackgroundfor WCAG AA compliance (default ratio 4.5:1). -
lighten(
double amount) → Color -
Available on Color, provided by the ColorUtils extension
Lightens this color byamount(0..1) in HSL space. -
mix(
Color other, double t) → Color -
Available on Color, provided by the ColorUtils extension
Linearly interpolates between this color andotherby factort(0..1). -
shade(
int level) → Color -
Available on Color, provided by the ColorUtils extension
Returns a shade of this color by mixing it with black bylevel% (0–100). -
tint(
int level) → Color -
Available on Color, provided by the ColorUtils extension
Returns a tint of this color by mixing it with white bylevel% (0–100). -
toArgb(
) → int -
Available on Color, provided by the ColorUtils extension
Returns the ARGB integer value of this color. -
toHex(
{bool includeAlpha = false, bool upperCase = true}) → String -
Available on Color, provided by the ColorUtils extension
Returns the hex string representation of this color. -
toMaterialColor(
) → MaterialColor -
Available on Color, provided by the ColorUtils extension
Generates a MaterialColor swatch from this color. -
withHue(
double hue) → Color -
Available on Color, provided by the ColorUtils extension
Returns a copy of this color with the given HSLhue(0..360). -
withLightness(
double lightness) → Color -
Available on Color, provided by the ColorUtils extension
Returns a copy of this color with the given HSLlightness(0..1). -
withOpacityPercent(
int percent) → Color -
Available on Color, provided by the ColorUtils extension
Returns a copy of this color with opacity set topercent% (0–100). -
withSaturation(
double saturation) → Color -
Available on Color, provided by the ColorUtils extension
Returns a copy of this color with the given HSLsaturation(0..1).