ContrastRule class

Flags Text widgets whose resolved color has insufficient contrast against the nearest solid background behind them.

Background is detected by walking up from the text's element to the first ancestor widget that paints an opaque color — ColoredBox, Container, DecoratedBox (with a BoxDecoration color), Material, or Scaffold. If none is found, the widget is skipped rather than guessed at, to avoid false positives.

Inheritance

Constructors

ContrastRule({A11yContrastLevel level = A11yContrastLevel.aa, double? minimumRatio})
minimumRatio, if set, overrides the WCAG-derived threshold for every text size — the hook for teams enforcing a brand contrast minimum stricter than WCAG.
const

Properties

description String
Short human-readable description of what this rule checks.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
id String
Stable identifier used in A11yViolation.ruleId and reports.
no setteroverride
level A11yContrastLevel
final
minimumRatio double?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

check(List<A11yElementInfo> elements) List<A11yViolation>
Inspects elements — a snapshot of the tree captured by the ElementTreeWalker — and returns any violations found.
override
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