Allow wrapping CheckBox in Semantics (#15259)

This commit is contained in:
Michael Goderbauer
2018-03-09 10:37:59 -08:00
committed by GitHub
parent 7d1ceb4080
commit 5d03a59379
2 changed files with 39 additions and 1 deletions

View File

@@ -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;

View File

@@ -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: <TestSemantics>[
new TestSemantics.rootChild(
id: 1,
label: 'foo',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.hasCheckedState,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
actions: <SemanticsAction>[
SemanticsAction.tap,
],
),
],
), ignoreRect: true, ignoreTransform: true));
semantics.dispose();
});
testWidgets('CheckBox tristate: true', (WidgetTester tester) async {
bool checkBoxValue;