Skip to content

Commit 37dff27

Browse files
authored
Add button semantics in list tile (#151599)
fixes: flutter/flutter#111960 ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 4d12197 commit 37dff27

File tree

7 files changed

+11
-0
lines changed

7 files changed

+11
-0
lines changed

packages/flutter/lib/src/material/list_tile.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ class ListTile extends StatelessWidget {
910910
autofocus: autofocus,
911911
enableFeedback: enableFeedback ?? tileTheme.enableFeedback ?? true,
912912
child: Semantics(
913+
button: onTap != null || onLongPress != null,
913914
selected: selected,
914915
enabled: enabled,
915916
child: Ink(

packages/flutter/test/material/checkbox_list_tile_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,7 @@ void main() {
11841184
));
11851185

11861186
expect(tester.getSemantics(find.byType(CheckboxListTile)), matchesSemantics(
1187+
isButton: true,
11871188
hasCheckedState: true,
11881189
isChecked: true,
11891190
hasEnabledState: true,

packages/flutter/test/material/expansion_tile_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ void main() {
727727
expect(
728728
tester.getSemantics(find.byType(ListTile).first),
729729
matchesSemantics(
730+
isButton: true,
730731
hasTapAction: true,
731732
hasFocusAction: true,
732733
hasEnabledState: true,
@@ -742,6 +743,7 @@ void main() {
742743
expect(
743744
tester.getSemantics(find.byType(ListTile).last),
744745
matchesSemantics(
746+
isButton: true,
745747
hasTapAction: true,
746748
hasFocusAction: true,
747749
hasEnabledState: true,

packages/flutter/test/material/list_tile_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ void main() {
304304
),
305305
TestSemantics.rootChild(
306306
flags: <SemanticsFlag>[
307+
SemanticsFlag.isButton,
307308
SemanticsFlag.hasEnabledState,
308309
SemanticsFlag.isEnabled,
309310
SemanticsFlag.isFocusable,

packages/flutter/test/material/radio_list_tile_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ void main() {
405405
TestSemantics(
406406
id: 1,
407407
flags: <SemanticsFlag>[
408+
SemanticsFlag.isButton,
408409
SemanticsFlag.hasCheckedState,
409410
SemanticsFlag.hasEnabledState,
410411
SemanticsFlag.isEnabled,
@@ -441,6 +442,7 @@ void main() {
441442
TestSemantics(
442443
id: 1,
443444
flags: <SemanticsFlag>[
445+
SemanticsFlag.isButton,
444446
SemanticsFlag.hasCheckedState,
445447
SemanticsFlag.isChecked,
446448
SemanticsFlag.hasEnabledState,

packages/flutter/test/material/reorderable_list_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ void main() {
744744
return false;
745745
});
746746
expect(child, matchesSemantics(
747+
isButton: true,
747748
hasToggledState: true,
748749
isToggled: true,
749750
isEnabled: true,

packages/flutter/test/material/switch_list_tile_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void main() {
7272
id: 1,
7373
rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
7474
flags: <SemanticsFlag>[
75+
SemanticsFlag.isButton,
7576
SemanticsFlag.hasEnabledState,
7677
SemanticsFlag.hasToggledState,
7778
SemanticsFlag.isEnabled,
@@ -86,6 +87,7 @@ void main() {
8687
rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
8788
transform: Matrix4.translationValues(0.0, 56.0, 0.0),
8889
flags: <SemanticsFlag>[
90+
SemanticsFlag.isButton,
8991
SemanticsFlag.hasCheckedState,
9092
SemanticsFlag.hasEnabledState,
9193
SemanticsFlag.isChecked,
@@ -100,6 +102,7 @@ void main() {
100102
rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
101103
transform: Matrix4.translationValues(0.0, 112.0, 0.0),
102104
flags: <SemanticsFlag>[
105+
SemanticsFlag.isButton,
103106
SemanticsFlag.hasCheckedState,
104107
SemanticsFlag.hasEnabledState,
105108
SemanticsFlag.isEnabled,

0 commit comments

Comments
 (0)