Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use correct semantics for toggle buttons #113851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/toggle_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ class ToggleButtons extends StatelessWidget {
return MergeSemantics(
child: Semantics(
container: true,
toggled: isSelected[index],
checked: isSelected[index],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semantics also has an inMutuallyExclusiveGroup attribute, which may or may not apply to ToggleButtons. Is it appropriate and feasible to include that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah looks like this would have to be implemented by the caller since it's not actually a primary feature of ToggleButtons, never mind.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed!

enabled: onPressed != null,
child: _InputPadding(
minSize: minPaddingSize,
Expand Down
14 changes: 7 additions & 7 deletions packages/flutter/test/material/toggle_buttons_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,7 @@ void main() {
SemanticsFlag.isButton,
SemanticsFlag.isEnabled,
SemanticsFlag.hasEnabledState,
SemanticsFlag.hasToggledState,
SemanticsFlag.hasCheckedState,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[
Expand All @@ -2019,7 +2019,7 @@ void main() {
SemanticsFlag.isButton,
SemanticsFlag.isEnabled,
SemanticsFlag.hasEnabledState,
SemanticsFlag.hasToggledState,
SemanticsFlag.hasCheckedState,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[
Expand All @@ -2032,7 +2032,7 @@ void main() {
SemanticsFlag.isButton,
SemanticsFlag.isEnabled,
SemanticsFlag.hasEnabledState,
SemanticsFlag.hasToggledState,
SemanticsFlag.hasCheckedState,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[
Expand All @@ -2051,7 +2051,7 @@ void main() {
semantics.dispose();
});

testWidgets('Toggle buttons have correct semantics', (WidgetTester tester) async {
testWidgets('Toggle buttons have correct semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);

await tester.pumpWidget(
Expand Down Expand Up @@ -2079,7 +2079,7 @@ void main() {
SemanticsFlag.isButton,
SemanticsFlag.isEnabled,
SemanticsFlag.hasEnabledState,
SemanticsFlag.hasToggledState,
SemanticsFlag.hasCheckedState,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[
Expand All @@ -2091,8 +2091,8 @@ void main() {
SemanticsFlag.isButton,
SemanticsFlag.isEnabled,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isToggled,
SemanticsFlag.hasToggledState,
SemanticsFlag.isChecked,
SemanticsFlag.hasCheckedState,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[
Expand Down