testing library

A flutter test harness for flutter_a11y_lens — separate from the main package:flutter_a11y_lens/a11y_lens.dart import so apps that don't test with it aren't pulled into a flutter_test dependency at runtime.

testWidgets('home screen has no accessibility violations', (tester) async {
  await tester.pumpWidget(const MyApp());
  await expectNoA11yViolations(tester);
});

Classes

A11yElementInfo
A snapshot of one Element captured while walking the live widget tree.
A11yLensOverlay
Wrap the root of an app in A11yLensOverlay to audit it live:
A11yReport
A point-in-time snapshot of every violation found below a BuildContext, exportable as JSON or Markdown — the CI/report counterpart to A11yLensOverlay's live view.
A11yRule
A single accessibility check that can be run against a captured widget tree snapshot.
A11ySemanticsNodeInfo
A snapshot of one SemanticsNode captured while walking the live accessibility tree — the merged tree the engine hands to screen readers and switch access, as opposed to the raw Element tree A11yElementInfo snapshots.
A11ySemanticsRule
A check that runs against a SemanticsTreeWalker snapshot rather than an ElementTreeWalker one — the counterpart to A11yRule for issues that can only be caught by reading the actual accessibility tree (missing labels on widgets that set semantics via a custom RenderObject, focus order, ...).
A11yViolation
A single accessibility issue found by an A11yRule on a live widget.
ColorContrast
WCAG 2.x color math: relative luminance and contrast ratio.
ContrastRule
Flags Text widgets whose resolved color has insufficient contrast against the nearest solid background behind them.
ElementTreeWalker
Walks the live Element tree below a BuildContext and captures a snapshot of every descendant: widget type, global render bounds, and any explicit Semantics it carries.
FocusOrderRule
Flags sibling groups of interactive semantics nodes whose traversal order — the order a screen reader or switch-access user would move through them — doesn't match their visual reading order (top-to-bottom, then left-to-right).
SemanticLabelRule
Flags semantics nodes that are interactive (expose a tap or long-press action) but carry no label, value, or tooltip for assistive technology to announce.
SemanticsTreeWalker
Walks the live SemanticsNode tree and captures a flat, depth-first snapshot of it as A11ySemanticsNodeInfo.
TapTargetSizeRule
Flags interactive widgets whose tap target is smaller than minimumSize in either dimension.

Enums

A11yContrastLevel
Which WCAG conformance level ContrastRule enforces.
A11ySeverity
How serious an A11yViolation is.

Functions

expectNoA11yViolations(WidgetTester tester, {Finder? finder, List<A11yRule> rules = const [ContrastRule(), TapTargetSizeRule()], List<A11ySemanticsRule> semanticsRules = const [SemanticLabelRule(), FocusOrderRule()], A11ySeverity minimumSeverity = A11ySeverity.warning, A11yReport? baseline}) Future<void>
Fails the current test if A11yReport.generate finds any violation at or above minimumSeverity below finder (the whole app, if omitted).