Add toggled semantics to ToggleButtons
(#106096)
This commit is contained in:
parent
fe41b6abcd
commit
912b81f6bf
@ -790,6 +790,7 @@ class ToggleButtons extends StatelessWidget {
|
||||
return MergeSemantics(
|
||||
child: Semantics(
|
||||
container: true,
|
||||
toggled: isSelected[index],
|
||||
enabled: onPressed != null,
|
||||
child: _InputPadding(
|
||||
minSize: minPaddingSize,
|
||||
|
@ -2006,6 +2006,7 @@ void main() {
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isEnabled,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.hasToggledState,
|
||||
SemanticsFlag.isFocusable,
|
||||
],
|
||||
actions: <SemanticsAction>[
|
||||
@ -2018,6 +2019,7 @@ void main() {
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isEnabled,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.hasToggledState,
|
||||
SemanticsFlag.isFocusable,
|
||||
],
|
||||
actions: <SemanticsAction>[
|
||||
@ -2030,6 +2032,7 @@ void main() {
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isEnabled,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.hasToggledState,
|
||||
SemanticsFlag.isFocusable,
|
||||
],
|
||||
actions: <SemanticsAction>[
|
||||
@ -2045,6 +2048,65 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('Toggle buttons have correct semantics', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
child: boilerplate(
|
||||
child: ToggleButtons(
|
||||
isSelected: const <bool>[false, true],
|
||||
onPressed: (int index) {},
|
||||
children: const <Widget>[
|
||||
Icon(Icons.check),
|
||||
Icon(Icons.access_alarm),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
semantics,
|
||||
hasSemantics(
|
||||
TestSemantics.root(
|
||||
children: <TestSemantics>[
|
||||
TestSemantics(
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isEnabled,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.hasToggledState,
|
||||
SemanticsFlag.isFocusable,
|
||||
],
|
||||
actions: <SemanticsAction>[
|
||||
SemanticsAction.tap,
|
||||
],
|
||||
),
|
||||
TestSemantics(
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isEnabled,
|
||||
SemanticsFlag.hasEnabledState,
|
||||
SemanticsFlag.isToggled,
|
||||
SemanticsFlag.hasToggledState,
|
||||
SemanticsFlag.isFocusable,
|
||||
],
|
||||
actions: <SemanticsAction>[
|
||||
SemanticsAction.tap,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
ignoreId: true,
|
||||
ignoreRect: true,
|
||||
ignoreTransform: true,
|
||||
),
|
||||
);
|
||||
|
||||
semantics.dispose();
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user