flutter_accessibility_scanner 1.2.0
flutter_accessibility_scanner: ^1.2.0 copied to clipboard
Scan Flutter widget trees for WCAG 2.1 accessibility issues (missing labels, low contrast, small tap targets, focus) with fix hints and JSON reports.
1.2.0 #
Reports for CI. Backward compatible with 1.1.
AccessibilityReport.passes(failOn:): one-line severity gate for tests and CI (a failing expectation makesflutter testexit non-zero).- Richer JSON:
schemaVersion,issuesByTypeandissuesByWcagCriterioncounts; each issue also carries shortruleandlevelnames.toJson(pretty: true)writes indented, diff-friendly output. AccessibilityReport.fromJson/fromMapandAccessibilityIssue.fromJsonread reports back, e.g. to compare against a saved baseline.AccessibilityReport.toMarkdown()for pull request comments and$GITHUB_STEP_SUMMARY;issueCountsByWcagCriterion.- README: "In CI" section with a GitHub Actions example and exit codes.
1.1.0 #
Accuracy, API and tooling overhaul. Source compatible with 1.0; scan results are more precise, so issue counts will change.
Detection #
- Interactive elements are now found precisely from their gesture handlers
(
GestureDetector,InkWell, every Material button) instead of guessing from render-object type names, which removes most false positives from scroll views, pointer listeners and plain containers. - Missing labels: a control counts as named when it contains visible text
or has a
Semanticslabel,Tooltip, orIcon.semanticLabel, including throughMergeSemantics(e.g.CheckboxListTile). Icon glyphs no longer count as a label. - New
ImageLabelDetector: reports images withoutsemanticLabelthat are not markedexcludeFromSemantics(WCAG 1.1.1). - Contrast: reads backgrounds from
Container/ColoredBox,DecoratedBox,Material,CardandScaffold, blends translucent layers and text colors, honours the text scale factor, uses the correct WCAG "large text" size (24 px, or 18.66 px bold), and checks icon glyphs against the 3:1 non-text threshold (WCAG 1.4.11). - Tap targets: accounts for the invisible 48x48 padding Material adds
around small buttons; minimum size is configurable
(
TapTargetDetector(minimumSize: 44)). - Focus: only reports controls that genuinely cannot take keyboard focus
(e.g. a bare
GestureDetector);InkWelland buttons pass. - Offstage content (such as routes behind the current page) is skipped.
API #
AccessibilityScanner(detectors: [...])runs a custom set of detectors, including your ownAccessibilityDetectorsubclasses.scan(context, minimumSeverity: ...)andscanRenderObject(root).- Issues are sorted most severe first and carry
wcagCriterionand global screenbounds. AccessibilityReport:hasIssues,issuesByType,issuesAtLeast,issuesOfType,toMap,scannedElements,scanDuration.ColorContrastUtils:relativeLuminance,composite,wcagLevel,toHex;suggestBetterColornow always returns a passing color with the smallest change.AccessibilityScannerWidget: outlines each issue on screen, lists issues with their WCAG criterion, addsonReport,scanner,minimumSeverity,showHighlightsandoverlayDuration, and no longer scans its own button.AccessibilityFixerButton: addstooltip,focusNode,autofocusandborderRadius; no longer inserts a redundant focus stop or stretches to fill its parent.AccessibilityFixerText:backgroundColornow actually enforces AA contrast; long text is no longer truncated for screen readers. AddstextAlign,maxLinesandoverflow.- All detectors have
constconstructors.
Maintenance #
- Removed debug
printoutput from scans. - Migrated off deprecated
ColorAPIs; requires Flutter 3.27+ / Dart 3.6+. - Fixed pubspec URLs, shortened the description and added topics.
- Clean static analysis, full API docs, new tests, CI and automated publishing.
1.0.0 #
Initial Release #
-
β¨ Core Features
- Automatic widget tree scanning for accessibility issues
- WCAG 2.1 AA compliance checking
- Real-time development scanning with visual feedback
- JSON report generation with detailed issue metadata
-
π Issue Detection
- Missing semantic labels and descriptions
- Poor color contrast ratios (below 4.5:1 WCAG standard)
- Tap targets smaller than 48x48 logical pixels
- Missing keyboard focus support
-
π οΈ Developer Tools
AccessibilityScanner- Main scanning engineAccessibilityScannerWidget- Real-time development overlayAccessibilityFixerButton- Helper widget for accessible buttonsAccessibilityFixerText- Helper widget for accessible textColorContrastUtils- WCAG color contrast calculations
-
π Reporting
- Detailed accessibility reports with severity levels
- JSON export functionality
- Issue grouping by severity (Critical, High, Medium, Low)
- Actionable suggestions for each detected issue
-
π§ͺ Testing Integration
- Widget test compatibility
- Comprehensive test suite with 16 passing tests
- Integration test examples
-
π Documentation
- Complete API documentation
- Beginner-friendly examples
- WCAG 2.1 guidelines mapping
- Best practices guide