diff --git a/packages/flutter_test/lib/src/accessibility.dart b/packages/flutter_test/lib/src/accessibility.dart index 63506e2487..0adfda1772 100644 --- a/packages/flutter_test/lib/src/accessibility.dart +++ b/packages/flutter_test/lib/src/accessibility.dart @@ -95,6 +95,9 @@ class MinimumTapTargetGuideline extends AccessibilityGuideline { && !data.hasAction(ui.SemanticsAction.tap)) || data.hasFlag(ui.SemanticsFlag.isHidden)) return result; + // Skip links https://www.w3.org/WAI/WCAG21/Understanding/target-size.html + if (data.hasFlag(ui.SemanticsFlag.isLink)) + return result; Rect paintBounds = node.rect; SemanticsNode? current = node; while (current != null) { diff --git a/packages/flutter_test/test/accessibility_test.dart b/packages/flutter_test/test/accessibility_test.dart index 9690dab116..fdf3c36c97 100644 --- a/packages/flutter_test/test/accessibility_test.dart +++ b/packages/flutter_test/test/accessibility_test.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -518,6 +519,35 @@ void main() { expect(overlappingRightResult.passed, true); handle.dispose(); }); + + testWidgets('Does not fail on links', (WidgetTester tester) async { + Widget textWithLink() { + return Builder( + builder: (BuildContext context) { + return RichText( + text: TextSpan( + children: [ + const TextSpan( + text: 'See examples at ', + ), + TextSpan( + text: 'flutter repo', + recognizer: TapGestureRecognizer() + ..onTap = () { }, + ), + ], + ), + ); + }, + ); + } + + final SemanticsHandle handle = tester.ensureSemantics(); + await tester.pumpWidget(_boilerplate(textWithLink())); + + await expectLater(tester, meetsGuideline(androidTapTargetGuideline)); + handle.dispose(); + }); }); group('Labeled tappable node guideline', () {