diff --git a/packages/flutter/lib/src/material/navigation_bar.dart b/packages/flutter/lib/src/material/navigation_bar.dart index f55b3602e4..d24344bb7a 100644 --- a/packages/flutter/lib/src/material/navigation_bar.dart +++ b/packages/flutter/lib/src/material/navigation_bar.dart @@ -996,6 +996,7 @@ class _NavigationBarDestinationSemantics extends StatelessWidget { return Semantics( selected: destinationInfo.selectedAnimation.isForwardOrCompleted, container: true, + button: true, child: child, ); }, diff --git a/packages/flutter/test/material/navigation_bar_test.dart b/packages/flutter/test/material/navigation_bar_test.dart index 3b21f4695b..244e664b23 100644 --- a/packages/flutter/test/material/navigation_bar_test.dart +++ b/packages/flutter/test/material/navigation_bar_test.dart @@ -460,6 +460,7 @@ void main() { destinations: const [ NavigationDestination(icon: Icon(Icons.ac_unit), label: 'AC'), NavigationDestination(icon: Icon(Icons.access_alarm), label: 'Alarm'), + NavigationDestination(icon: Icon(Icons.abc), label: 'ABC'), ], ), ); @@ -470,10 +471,11 @@ void main() { expect( tester.getSemantics(find.text('AC')), matchesSemantics( - label: 'AC\nTab 1 of 2', + label: 'AC\nTab 1 of 3', textDirection: TextDirection.ltr, isFocusable: true, isSelected: true, + isButton: true, hasTapAction: true, hasFocusAction: true, ), @@ -481,9 +483,21 @@ void main() { expect( tester.getSemantics(find.text('Alarm')), matchesSemantics( - label: 'Alarm\nTab 2 of 2', + label: 'Alarm\nTab 2 of 3', textDirection: TextDirection.ltr, isFocusable: true, + isButton: true, + hasTapAction: true, + hasFocusAction: true, + ), + ); + expect( + tester.getSemantics(find.text('ABC')), + matchesSemantics( + label: 'ABC\nTab 3 of 3', + textDirection: TextDirection.ltr, + isFocusable: true, + isButton: true, hasTapAction: true, hasFocusAction: true, ), @@ -494,9 +508,10 @@ void main() { expect( tester.getSemantics(find.text('AC')), matchesSemantics( - label: 'AC\nTab 1 of 2', + label: 'AC\nTab 1 of 3', textDirection: TextDirection.ltr, isFocusable: true, + isButton: true, hasTapAction: true, hasFocusAction: true, ), @@ -504,10 +519,22 @@ void main() { expect( tester.getSemantics(find.text('Alarm')), matchesSemantics( - label: 'Alarm\nTab 2 of 2', + label: 'Alarm\nTab 2 of 3', textDirection: TextDirection.ltr, isFocusable: true, isSelected: true, + isButton: true, + hasTapAction: true, + hasFocusAction: true, + ), + ); + expect( + tester.getSemantics(find.text('ABC')), + matchesSemantics( + label: 'ABC\nTab 3 of 3', + textDirection: TextDirection.ltr, + isFocusable: true, + isButton: true, hasTapAction: true, hasFocusAction: true, ), @@ -537,6 +564,7 @@ void main() { textDirection: TextDirection.ltr, isFocusable: true, isSelected: true, + isButton: true, hasTapAction: true, hasFocusAction: true, ), @@ -547,6 +575,7 @@ void main() { label: 'Alarm\nTab 2 of 2', textDirection: TextDirection.ltr, isFocusable: true, + isButton: true, hasTapAction: true, hasFocusAction: true, ), @@ -560,6 +589,7 @@ void main() { label: 'AC\nTab 1 of 2', textDirection: TextDirection.ltr, isFocusable: true, + isButton: true, hasTapAction: true, hasFocusAction: true, ), @@ -571,6 +601,7 @@ void main() { textDirection: TextDirection.ltr, isFocusable: true, isSelected: true, + isButton: true, hasTapAction: true, hasFocusAction: true, ),