@@ -58,6 +58,34 @@ class Evaluation {
58
58
59
59
/// An accessibility guideline describes a recommendation an application should
60
60
/// meet to be considered accessible.
61
+ ///
62
+ /// Use [meetsGuideline] matcher to test whether a screen meets the
63
+ /// accessibility guideline.
64
+ ///
65
+ /// {@tool snippet}
66
+ ///
67
+ /// This sample demonstrates how to run an accessibility guideline in a unit
68
+ /// test against a single screen.
69
+ ///
70
+ /// ```dart
71
+ /// testWidgets('HomePage meets androidTapTargetGuideline', (WidgetTester tester) async {
72
+ /// final SemanticsHandle handle = tester.ensureSemantics();
73
+ /// await tester.pumpWidget(const MaterialApp(home: HomePage()));
74
+ /// await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
75
+ /// handle.dispose();
76
+ /// });
77
+ /// ```
78
+ /// {@end-tool}
79
+ ///
80
+ /// See also:
81
+ /// * [androidTapTargetGuideline] , which checks that tappable nodes have a
82
+ /// minimum size of 48 by 48 pixels.
83
+ /// * [iOSTapTargetGuideline] , which checks that tappable nodes have a minimum
84
+ /// size of 44 by 44 pixels.
85
+ /// * [textContrastGuideline] , which provides guidance for text contrast
86
+ /// requirements specified by [WCAG](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html#contrast-ratiodef).
87
+ /// * [labeledTapTargetGuideline] , which enforces that all nodes with a tap or
88
+ /// long press action also have a label.
61
89
abstract class AccessibilityGuideline {
62
90
/// A const constructor allows subclasses to be const.
63
91
const AccessibilityGuideline ();
@@ -73,6 +101,14 @@ abstract class AccessibilityGuideline {
73
101
/// size.
74
102
///
75
103
/// Each platform defines its own guidelines for minimum tap areas.
104
+ ///
105
+ /// See also:
106
+ /// * [AccessibilityGuideline] , which provides a general overview of
107
+ /// accessibility guidelines and how to use them.
108
+ /// * [androidTapTargetGuideline] , which checks that tappable nodes have a
109
+ /// minimum size of 48 by 48 pixels.
110
+ /// * [iOSTapTargetGuideline] , which checks that tappable nodes have a minimum
111
+ /// size of 44 by 44 pixels.
76
112
@visibleForTesting
77
113
class MinimumTapTargetGuideline extends AccessibilityGuideline {
78
114
/// Create a new [MinimumTapTargetGuideline] .
@@ -161,6 +197,10 @@ class MinimumTapTargetGuideline extends AccessibilityGuideline {
161
197
162
198
/// A guideline which enforces that all nodes with a tap or long press action
163
199
/// also have a label.
200
+ ///
201
+ /// See also:
202
+ /// * [AccessibilityGuideline] , which provides a general overview of
203
+ /// accessibility guidelines and how to use them.
164
204
@visibleForTesting
165
205
class LabeledTapTargetGuideline extends AccessibilityGuideline {
166
206
const LabeledTapTargetGuideline ._();
@@ -206,6 +246,10 @@ class LabeledTapTargetGuideline extends AccessibilityGuideline {
206
246
///
207
247
/// The guidelines are defined by the Web Content Accessibility Guidelines,
208
248
/// http://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html.
249
+ ///
250
+ /// See also:
251
+ /// * [AccessibilityGuideline] , which provides a general overview of
252
+ /// accessibility guidelines and how to use them.
209
253
@visibleForTesting
210
254
class MinimumTextContrastGuideline extends AccessibilityGuideline {
211
255
/// Create a new [MinimumTextContrastGuideline] .
@@ -401,6 +445,10 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
401
445
402
446
/// A guideline which verifies that all elements specified by [finder]
403
447
/// meet minimum contrast levels.
448
+ ///
449
+ /// See also:
450
+ /// * [AccessibilityGuideline] , which provides a general overview of
451
+ /// accessibility guidelines and how to use them.
404
452
class CustomMinimumContrastGuideline extends AccessibilityGuideline {
405
453
/// Creates a custom guideline which verifies that all elements specified
406
454
/// by [finder] meet minimum contrast levels.
@@ -617,6 +665,10 @@ Map<Color, int> _colorsWithinRect(
617
665
/// See also:
618
666
///
619
667
/// * [Android tap target guidelines] (https://support.google.com/accessibility/android/answer/7101858?hl=en).
668
+ /// * [AccessibilityGuideline] , which provides a general overview of
669
+ /// accessibility guidelines and how to use them.
670
+ /// * [iOSTapTargetGuideline] , which checks that tappable nodes have a minimum
671
+ /// size of 44 by 44 pixels.
620
672
const AccessibilityGuideline androidTapTargetGuideline = MinimumTapTargetGuideline (
621
673
size: Size (48.0 , 48.0 ),
622
674
link: 'https://support.google.com/accessibility/android/answer/7101858?hl=en' ,
@@ -627,7 +679,11 @@ const AccessibilityGuideline androidTapTargetGuideline = MinimumTapTargetGuideli
627
679
///
628
680
/// See also:
629
681
///
630
- /// * [iOS human interface guidelines] (https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/adaptivity-and-layout/).
682
+ /// * [iOS human interface guidelines] (https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/adaptivity-and-layout/).
683
+ /// * [AccessibilityGuideline] , which provides a general overview of
684
+ /// accessibility guidelines and how to use them.
685
+ /// * [androidTapTargetGuideline] , which checks that tappable nodes have a
686
+ /// minimum size of 48 by 48 pixels.
631
687
const AccessibilityGuideline iOSTapTargetGuideline = MinimumTapTargetGuideline (
632
688
size: Size (44.0 , 44.0 ),
633
689
link: 'https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/adaptivity-and-layout/' ,
@@ -642,8 +698,14 @@ const AccessibilityGuideline iOSTapTargetGuideline = MinimumTapTargetGuideline(
642
698
/// frequently occurring color in each partition as a representative of the
643
699
/// foreground and background colors. The contrast ratio is calculated from
644
700
/// these colors according to the [WCAG] (https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html#contrast-ratiodef)
701
+ ///
702
+ /// * [AccessibilityGuideline] , which provides a general overview of
703
+ /// accessibility guidelines and how to use them.
645
704
const AccessibilityGuideline textContrastGuideline = MinimumTextContrastGuideline ();
646
705
647
706
/// A guideline which enforces that all nodes with a tap or long press action
648
707
/// also have a label.
708
+ ///
709
+ /// * [AccessibilityGuideline] , which provides a general overview of
710
+ /// accessibility guidelines and how to use them.
649
711
const AccessibilityGuideline labeledTapTargetGuideline = LabeledTapTargetGuideline ._();
0 commit comments