From 5d03a5937963b93cc3e682e414f285a3560ec631 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Fri, 9 Mar 2018 10:37:59 -0800 Subject: [PATCH] Allow wrapping CheckBox in Semantics (#15259) --- .../flutter/lib/src/material/toggleable.dart | 1 - .../flutter/test/material/checkbox_test.dart | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/toggleable.dart b/packages/flutter/lib/src/material/toggleable.dart index 505d8caeaf..8c0bdefdb2 100644 --- a/packages/flutter/lib/src/material/toggleable.dart +++ b/packages/flutter/lib/src/material/toggleable.dart @@ -329,7 +329,6 @@ abstract class RenderToggleable extends RenderConstrainedBox { void describeSemanticsConfiguration(SemanticsConfiguration config) { super.describeSemanticsConfiguration(config); - config.isSemanticBoundary = true; config.isEnabled = isInteractive; if (isInteractive) config.onTap = _handleTap; diff --git a/packages/flutter/test/material/checkbox_test.dart b/packages/flutter/test/material/checkbox_test.dart index beb15b6367..cea2edca26 100644 --- a/packages/flutter/test/material/checkbox_test.dart +++ b/packages/flutter/test/material/checkbox_test.dart @@ -11,6 +11,10 @@ import 'package:flutter/material.dart'; import '../widgets/semantics_tester.dart'; void main() { + setUp(() { + debugResetSemanticsIdCounter(); + }); + testWidgets('CheckBox semantics', (WidgetTester tester) async { final SemanticsTester semantics = new SemanticsTester(tester); @@ -103,6 +107,41 @@ void main() { semantics.dispose(); }); + testWidgets('Can wrap CheckBox with Semantics', (WidgetTester tester) async { + final SemanticsTester semantics = new SemanticsTester(tester); + + await tester.pumpWidget(new Material( + child: new Semantics( + label: 'foo', + textDirection: TextDirection.ltr, + child: new Checkbox( + value: false, + onChanged: (bool b) { }, + ), + ), + )); + + expect(semantics, hasSemantics(new TestSemantics.root( + children: [ + new TestSemantics.rootChild( + id: 1, + label: 'foo', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasCheckedState, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + ], + actions: [ + SemanticsAction.tap, + ], + ), + ], + ), ignoreRect: true, ignoreTransform: true)); + + semantics.dispose(); + }); + testWidgets('CheckBox tristate: true', (WidgetTester tester) async { bool checkBoxValue;