Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
912b81f6
Unverified
Commit
912b81f6
authored
Jun 23, 2022
by
Pierre-Louis
Committed by
GitHub
Jun 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add toggled semantics to `ToggleButtons` (#106096)
parent
fe41b6ab
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
toggle_buttons.dart
packages/flutter/lib/src/material/toggle_buttons.dart
+1
-0
toggle_buttons_test.dart
packages/flutter/test/material/toggle_buttons_test.dart
+62
-0
No files found.
packages/flutter/lib/src/material/toggle_buttons.dart
View file @
912b81f6
...
@@ -790,6 +790,7 @@ class ToggleButtons extends StatelessWidget {
...
@@ -790,6 +790,7 @@ class ToggleButtons extends StatelessWidget {
return
MergeSemantics
(
return
MergeSemantics
(
child:
Semantics
(
child:
Semantics
(
container:
true
,
container:
true
,
toggled:
isSelected
[
index
],
enabled:
onPressed
!=
null
,
enabled:
onPressed
!=
null
,
child:
_InputPadding
(
child:
_InputPadding
(
minSize:
minPaddingSize
,
minSize:
minPaddingSize
,
...
...
packages/flutter/test/material/toggle_buttons_test.dart
View file @
912b81f6
...
@@ -2006,6 +2006,7 @@ void main() {
...
@@ -2006,6 +2006,7 @@ void main() {
SemanticsFlag
.
isButton
,
SemanticsFlag
.
isButton
,
SemanticsFlag
.
isEnabled
,
SemanticsFlag
.
isEnabled
,
SemanticsFlag
.
hasEnabledState
,
SemanticsFlag
.
hasEnabledState
,
SemanticsFlag
.
hasToggledState
,
SemanticsFlag
.
isFocusable
,
SemanticsFlag
.
isFocusable
,
],
],
actions:
<
SemanticsAction
>[
actions:
<
SemanticsAction
>[
...
@@ -2018,6 +2019,7 @@ void main() {
...
@@ -2018,6 +2019,7 @@ void main() {
SemanticsFlag
.
isButton
,
SemanticsFlag
.
isButton
,
SemanticsFlag
.
isEnabled
,
SemanticsFlag
.
isEnabled
,
SemanticsFlag
.
hasEnabledState
,
SemanticsFlag
.
hasEnabledState
,
SemanticsFlag
.
hasToggledState
,
SemanticsFlag
.
isFocusable
,
SemanticsFlag
.
isFocusable
,
],
],
actions:
<
SemanticsAction
>[
actions:
<
SemanticsAction
>[
...
@@ -2030,6 +2032,7 @@ void main() {
...
@@ -2030,6 +2032,7 @@ void main() {
SemanticsFlag
.
isButton
,
SemanticsFlag
.
isButton
,
SemanticsFlag
.
isEnabled
,
SemanticsFlag
.
isEnabled
,
SemanticsFlag
.
hasEnabledState
,
SemanticsFlag
.
hasEnabledState
,
SemanticsFlag
.
hasToggledState
,
SemanticsFlag
.
isFocusable
,
SemanticsFlag
.
isFocusable
,
],
],
actions:
<
SemanticsAction
>[
actions:
<
SemanticsAction
>[
...
@@ -2045,6 +2048,65 @@ void main() {
...
@@ -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
();
semantics
.
dispose
();
});
});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment