ColorContrast class abstract final

WCAG 2.x color math: relative luminance and contrast ratio.

See https://www.w3.org/TR/WCAG21/#dfn-relative-luminance and https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

compositeOver(Color foreground, Color background) Color
Alpha-composites foreground over an opaque background, returning the resulting opaque color. Returns foreground unchanged if it is already opaque.
contrastRatio(Color a, Color b) double
The WCAG contrast ratio between a and b, in the range [1, 21]. Order of arguments does not matter.
relativeLuminance(Color color) double
The relative luminance of color, in the range [0, 1].

Constants

aaaLargeText → const double
WCAG AAA minimum contrast ratio for large-scale text.
aaaNormalText → const double
WCAG AAA minimum contrast ratio for normal-size text.
aaLargeText → const double
WCAG AA minimum contrast ratio for large-scale text (>=18pt, or
aaNormalText → const double
WCAG AA minimum contrast ratio for normal-size text.