update Tristate checkbox semantics to consider indeterminate as "unchecked" (#18297)
This commit is contained in:
@@ -339,7 +339,7 @@ abstract class RenderToggleable extends RenderConstrainedBox {
|
||||
config.isEnabled = isInteractive;
|
||||
if (isInteractive)
|
||||
config.onTap = _handleTap;
|
||||
config.isChecked = _value != false;
|
||||
config.isChecked = _value == true;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -202,6 +202,69 @@ void main() {
|
||||
expect(checkBoxValue, null);
|
||||
});
|
||||
|
||||
testWidgets('has semantics for tristate', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = new SemanticsTester(tester);
|
||||
await tester.pumpWidget(
|
||||
new Material(
|
||||
child: new Checkbox(
|
||||
tristate: true,
|
||||
value: null,
|
||||
onChanged: (bool newValue) {},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(semantics.nodesWith(
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.hasCheckedState,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isEnabled
|
||||
],
|
||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
||||
), hasLength(1));
|
||||
|
||||
await tester.pumpWidget(
|
||||
new Material(
|
||||
child: new Checkbox(
|
||||
tristate: true,
|
||||
value: true,
|
||||
onChanged: (bool newValue) {},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(semantics.nodesWith(
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.hasCheckedState,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isEnabled,
|
||||
SemanticsFlag.isChecked,
|
||||
],
|
||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
||||
), hasLength(1));
|
||||
|
||||
await tester.pumpWidget(
|
||||
new Material(
|
||||
child: new Checkbox(
|
||||
tristate: true,
|
||||
value: false,
|
||||
onChanged: (bool newValue) {},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(semantics.nodesWith(
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.hasCheckedState,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isEnabled,
|
||||
],
|
||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
||||
), hasLength(1));
|
||||
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('has semantic events', (WidgetTester tester) async {
|
||||
dynamic semanticEvent;
|
||||
bool checkboxValue = false;
|
||||
|
||||
Reference in New Issue
Block a user