diff --git a/packages/flutter_test/test/accessibility_test.dart b/packages/flutter_test/test/accessibility_test.dart index c0dbb015cb..399a33e77f 100644 --- a/packages/flutter_test/test/accessibility_test.dart +++ b/packages/flutter_test/test/accessibility_test.dart @@ -43,6 +43,40 @@ void main() { handle.dispose(); }); + testWidgets('White text on white background fails contrast test', + (WidgetTester tester) async { + final SemanticsHandle handle = tester.ensureSemantics(); + await tester.pumpWidget( + _boilerplate( + Container( + width: 200.0, + height: 300.0, + color: Colors.white, + child: Column( + children: const [ + Text( + 'this is a white text', + style: TextStyle(fontSize: 14.0, color: Colors.white), + ), + SizedBox(height: 50), + Text( + 'this is a black text test1', + style: TextStyle(fontSize: 14.0, color: Colors.black), + ), + SizedBox(height: 50), + Text( + 'this is a black text test2', + style: TextStyle(fontSize: 14.0, color: Colors.black), + ), + ], + ), + ), + ), + ); + await expectLater(tester, doesNotMeetGuideline(textContrastGuideline)); + handle.dispose(); + }); + const Color surface = Color(0xFFF0F0F0); /// Shades of blue with contrast ratio of 2.9, 4.4, 4.5 from [surface].