diff --git a/packages/flutter/lib/src/material/navigation_bar.dart b/packages/flutter/lib/src/material/navigation_bar.dart index 8a1d882c85..8321778207 100644 --- a/packages/flutter/lib/src/material/navigation_bar.dart +++ b/packages/flutter/lib/src/material/navigation_bar.dart @@ -8,6 +8,9 @@ /// @docImport 'scaffold.dart'; library; +import 'dart:ui'; + +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'color_scheme.dart'; @@ -287,34 +290,45 @@ class NavigationBar extends StatelessWidget { surfaceTintColor ?? navigationBarTheme.surfaceTintColor ?? defaults.surfaceTintColor, child: SafeArea( maintainBottomViewPadding: maintainBottomViewPadding, - child: SizedBox( - height: effectiveHeight, - child: Row( - children: [ - for (int i = 0; i < destinations.length; i++) - Expanded( - child: _SelectableAnimatedBuilder( - duration: animationDuration ?? const Duration(milliseconds: 500), - isSelected: i == selectedIndex, - builder: (BuildContext context, Animation animation) { - return _NavigationDestinationInfo( - index: i, - selectedIndex: selectedIndex, - totalNumberOfDestinations: destinations.length, - selectedAnimation: animation, - labelBehavior: effectiveLabelBehavior, - indicatorColor: indicatorColor, - indicatorShape: indicatorShape, - overlayColor: overlayColor, - onTap: _handleTap(i), - labelTextStyle: labelTextStyle, - labelPadding: labelPadding, - child: destinations[i], - ); - }, + child: Semantics( + role: SemanticsRole.tabBar, + explicitChildNodes: true, + container: true, + child: SizedBox( + height: effectiveHeight, + child: Row( + children: [ + for (int i = 0; i < destinations.length; i++) + Expanded( + child: MergeSemantics( + child: Semantics( + role: SemanticsRole.tab, + selected: i == selectedIndex, + child: _SelectableAnimatedBuilder( + duration: animationDuration ?? const Duration(milliseconds: 500), + isSelected: i == selectedIndex, + builder: (BuildContext context, Animation animation) { + return _NavigationDestinationInfo( + index: i, + selectedIndex: selectedIndex, + totalNumberOfDestinations: destinations.length, + selectedAnimation: animation, + labelBehavior: effectiveLabelBehavior, + indicatorColor: indicatorColor, + indicatorShape: indicatorShape, + overlayColor: overlayColor, + onTap: _handleTap(i), + labelTextStyle: labelTextStyle, + labelPadding: labelPadding, + child: destinations[i], + ); + }, + ), + ), + ), ), - ), - ], + ], + ), ), ), ), @@ -581,6 +595,7 @@ class _NavigationDestinationBuilderState extends State<_NavigationDestinationBui final NavigationBarThemeData defaults = _defaultsFor(context); return _NavigationBarDestinationSemantics( + enabled: widget.enabled, child: _NavigationBarDestinationTooltip( message: widget.tooltip ?? widget.label, child: _IndicatorInkWell( @@ -983,7 +998,10 @@ class _DestinationLayoutAnimationBuilder extends StatelessWidget { class _NavigationBarDestinationSemantics extends StatelessWidget { /// Adds the appropriate semantics for navigation bar destinations to the /// [child]. - const _NavigationBarDestinationSemantics({required this.child}); + const _NavigationBarDestinationSemantics({required this.enabled, required this.child}); + + /// Whether this widget is enabled. + final bool enabled; /// The widget that should receive the destination semantics. final Widget child; @@ -997,25 +1015,23 @@ class _NavigationBarDestinationSemantics extends StatelessWidget { return _StatusTransitionWidgetBuilder( animation: destinationInfo.selectedAnimation, builder: (BuildContext context, Widget? child) { - return Semantics( - selected: destinationInfo.selectedAnimation.isForwardOrCompleted, - container: true, - button: true, - child: child, - ); + return Semantics(enabled: enabled, button: true, child: child); }, - child: Stack( - alignment: Alignment.center, - children: [ - child, - Semantics( - label: localizations.tabLabel( - tabIndex: destinationInfo.index + 1, - tabCount: destinationInfo.totalNumberOfDestinations, - ), - ), - ], - ), + child: + kIsWeb + ? child + : Stack( + alignment: Alignment.center, + children: [ + child, + Semantics( + label: localizations.tabLabel( + tabIndex: destinationInfo.index + 1, + tabCount: destinationInfo.totalNumberOfDestinations, + ), + ), + ], + ), ); } } diff --git a/packages/flutter/lib/src/semantics/semantics.dart b/packages/flutter/lib/src/semantics/semantics.dart index cb4d71450c..28984939ad 100644 --- a/packages/flutter/lib/src/semantics/semantics.dart +++ b/packages/flutter/lib/src/semantics/semantics.dart @@ -148,10 +148,17 @@ sealed class _DebugSemanticsRoleChecks { return FlutterError('A tab needs selected states'); } - if (!node.areUserActionsBlocked && !data.hasAction(SemanticsAction.tap)) { - return FlutterError('A tab must have a tap action'); + if (node.areUserActionsBlocked) { + return null; } + if (!data.hasFlag(SemanticsFlag.hasEnabledState)) { + if (!data.hasAction(SemanticsAction.tap)) { + return FlutterError('A tab must have a tap action'); + } + } else if (data.hasFlag(SemanticsFlag.isEnabled) && !data.hasAction(SemanticsAction.tap)) { + return FlutterError('A tab must have a tap action'); + } return null; } diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index d10e015429..fb4a8c4c19 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -1890,6 +1890,7 @@ void main() { isButton: true, isFocusable: true, isSelected: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), @@ -1901,6 +1902,7 @@ void main() { textDirection: TextDirection.ltr, isButton: true, isFocusable: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), @@ -1912,6 +1914,7 @@ void main() { textDirection: TextDirection.ltr, isButton: true, isFocusable: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), @@ -1941,6 +1944,7 @@ void main() { isButton: true, isFocusable: true, isSelected: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), @@ -1952,6 +1956,7 @@ void main() { textDirection: TextDirection.ltr, isButton: true, isFocusable: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), @@ -1963,6 +1968,7 @@ void main() { textDirection: TextDirection.ltr, isButton: true, isFocusable: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), @@ -2284,6 +2290,7 @@ void main() { isButton: true, isFocusable: true, isSelected: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), @@ -2295,6 +2302,7 @@ void main() { textDirection: TextDirection.ltr, isButton: true, isFocusable: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), @@ -2327,6 +2335,7 @@ void main() { textDirection: TextDirection.ltr, isButton: true, isFocusable: true, + hasSelectedState: true, isSelected: true, hasTapAction: true, hasFocusAction: true, @@ -2338,6 +2347,7 @@ void main() { label: 'Green\nTab 2 of 2', textDirection: TextDirection.ltr, isButton: true, + hasSelectedState: true, isFocusable: true, hasTapAction: true, hasFocusAction: true, diff --git a/packages/flutter/test/material/calendar_date_picker_test.dart b/packages/flutter/test/material/calendar_date_picker_test.dart index 3742776896..1c0da00dca 100644 --- a/packages/flutter/test/material/calendar_date_picker_test.dart +++ b/packages/flutter/test/material/calendar_date_picker_test.dart @@ -961,6 +961,7 @@ void main() { label: '1, Friday, January 1, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -971,6 +972,7 @@ void main() { label: '2, Saturday, January 2, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -981,6 +983,7 @@ void main() { label: '3, Sunday, January 3, 2016, Today', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -991,6 +994,7 @@ void main() { label: '4, Monday, January 4, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -1001,6 +1005,7 @@ void main() { label: '5, Tuesday, January 5, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -1011,6 +1016,7 @@ void main() { label: '6, Wednesday, January 6, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -1021,6 +1027,7 @@ void main() { label: '7, Thursday, January 7, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -1031,6 +1038,7 @@ void main() { label: '8, Friday, January 8, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -1041,6 +1049,7 @@ void main() { label: '9, Saturday, January 9, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -1051,6 +1060,7 @@ void main() { label: '10, Sunday, January 10, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -1061,6 +1071,7 @@ void main() { label: '11, Monday, January 11, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -1071,6 +1082,7 @@ void main() { label: '12, Tuesday, January 12, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -1081,6 +1093,7 @@ void main() { label: '13, Wednesday, January 13, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -1091,6 +1104,7 @@ void main() { label: '14, Thursday, January 14, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), @@ -1101,6 +1115,7 @@ void main() { label: '15, Friday, January 15, 2016', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isSelected: true, isFocusable: true, @@ -1111,6 +1126,7 @@ void main() { matchesSemantics( label: '16, Saturday, January 16, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1121,6 +1137,7 @@ void main() { matchesSemantics( label: '17, Sunday, January 17, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1131,6 +1148,7 @@ void main() { matchesSemantics( label: '18, Monday, January 18, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1141,6 +1159,7 @@ void main() { matchesSemantics( label: '19, Tuesday, January 19, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1151,6 +1170,7 @@ void main() { matchesSemantics( label: '20, Wednesday, January 20, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1161,6 +1181,7 @@ void main() { matchesSemantics( label: '21, Thursday, January 21, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1171,6 +1192,7 @@ void main() { matchesSemantics( label: '22, Friday, January 22, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1181,6 +1203,7 @@ void main() { matchesSemantics( label: '23, Saturday, January 23, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1191,6 +1214,7 @@ void main() { matchesSemantics( label: '24, Sunday, January 24, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1201,6 +1225,7 @@ void main() { matchesSemantics( label: '25, Monday, January 25, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1211,6 +1236,7 @@ void main() { matchesSemantics( label: '26, Tuesday, January 26, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1221,6 +1247,7 @@ void main() { matchesSemantics( label: '27, Wednesday, January 27, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1231,6 +1258,7 @@ void main() { matchesSemantics( label: '28, Thursday, January 28, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1241,6 +1269,7 @@ void main() { matchesSemantics( label: '29, Friday, January 29, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1251,6 +1280,7 @@ void main() { matchesSemantics( label: '30, Saturday, January 30, 2016', isButton: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, @@ -1290,6 +1320,7 @@ void main() { hasTapAction: true, hasFocusAction: true, isSelected: year == 2016, + hasSelectedState: true, isFocusable: true, isButton: true, ), diff --git a/packages/flutter/test/material/checkbox_list_tile_test.dart b/packages/flutter/test/material/checkbox_list_tile_test.dart index 5ccdc5e4d5..57ccc7b088 100644 --- a/packages/flutter/test/material/checkbox_list_tile_test.dart +++ b/packages/flutter/test/material/checkbox_list_tile_test.dart @@ -1232,6 +1232,7 @@ void main() { isChecked: true, hasEnabledState: true, isEnabled: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, isFocusable: true, diff --git a/packages/flutter/test/material/date_picker_test.dart b/packages/flutter/test/material/date_picker_test.dart index 9ff376a6ce..d2de44a065 100644 --- a/packages/flutter/test/material/date_picker_test.dart +++ b/packages/flutter/test/material/date_picker_test.dart @@ -1714,6 +1714,7 @@ void main() { label: '3, Sunday, January 3, 2016, Today', isButton: true, hasTapAction: true, + hasSelectedState: true, hasFocusAction: true, isFocusable: true, ), diff --git a/packages/flutter/test/material/date_range_picker_test.dart b/packages/flutter/test/material/date_range_picker_test.dart index 34b24b875d..4613914614 100644 --- a/packages/flutter/test/material/date_range_picker_test.dart +++ b/packages/flutter/test/material/date_range_picker_test.dart @@ -1471,6 +1471,7 @@ void main() { label: '30, Saturday, January 30, 2016, Today', hasTapAction: true, hasFocusAction: true, + hasSelectedState: true, isFocusable: true, ), ); diff --git a/packages/flutter/test/material/expansion_tile_test.dart b/packages/flutter/test/material/expansion_tile_test.dart index 5f9123396c..1fe5561d5b 100644 --- a/packages/flutter/test/material/expansion_tile_test.dart +++ b/packages/flutter/test/material/expansion_tile_test.dart @@ -755,6 +755,7 @@ void main() { hasTapAction: true, hasFocusAction: true, hasEnabledState: true, + hasSelectedState: true, isEnabled: true, isFocused: true, isFocusable: true, @@ -771,6 +772,7 @@ void main() { hasTapAction: true, hasFocusAction: true, hasEnabledState: true, + hasSelectedState: true, isEnabled: true, isFocusable: true, label: 'Second Expansion Tile', diff --git a/packages/flutter/test/material/navigation_bar_test.dart b/packages/flutter/test/material/navigation_bar_test.dart index 249a13d8ce..f7d16d5f56 100644 --- a/packages/flutter/test/material/navigation_bar_test.dart +++ b/packages/flutter/test/material/navigation_bar_test.dart @@ -470,11 +470,14 @@ void main() { expect( tester.getSemantics(find.text('AC')), matchesSemantics( - label: 'AC\nTab 1 of 3', + label: 'AC${kIsWeb ? '' : '\nTab 1 of 3'}', textDirection: TextDirection.ltr, isFocusable: true, isSelected: true, isButton: true, + hasSelectedState: true, + hasEnabledState: true, + isEnabled: true, hasTapAction: true, hasFocusAction: true, ), @@ -482,10 +485,13 @@ void main() { expect( tester.getSemantics(find.text('Alarm')), matchesSemantics( - label: 'Alarm\nTab 2 of 3', + label: 'Alarm${kIsWeb ? '' : '\nTab 2 of 3'}', textDirection: TextDirection.ltr, isFocusable: true, isButton: true, + hasSelectedState: true, + hasEnabledState: true, + isEnabled: true, hasTapAction: true, hasFocusAction: true, ), @@ -493,10 +499,13 @@ void main() { expect( tester.getSemantics(find.text('ABC')), matchesSemantics( - label: 'ABC\nTab 3 of 3', + label: 'ABC${kIsWeb ? '' : '\nTab 3 of 3'}', textDirection: TextDirection.ltr, isFocusable: true, isButton: true, + hasSelectedState: true, + hasEnabledState: true, + isEnabled: true, hasTapAction: true, hasFocusAction: true, ), @@ -507,10 +516,13 @@ void main() { expect( tester.getSemantics(find.text('AC')), matchesSemantics( - label: 'AC\nTab 1 of 3', + label: 'AC${kIsWeb ? '' : '\nTab 1 of 3'}', textDirection: TextDirection.ltr, isFocusable: true, isButton: true, + hasEnabledState: true, + hasSelectedState: true, + isEnabled: true, hasTapAction: true, hasFocusAction: true, ), @@ -518,11 +530,14 @@ void main() { expect( tester.getSemantics(find.text('Alarm')), matchesSemantics( - label: 'Alarm\nTab 2 of 3', + label: 'Alarm${kIsWeb ? '' : '\nTab 2 of 3'}', textDirection: TextDirection.ltr, isFocusable: true, isSelected: true, isButton: true, + hasEnabledState: true, + hasSelectedState: true, + isEnabled: true, hasTapAction: true, hasFocusAction: true, ), @@ -530,15 +545,45 @@ void main() { expect( tester.getSemantics(find.text('ABC')), matchesSemantics( - label: 'ABC\nTab 3 of 3', + label: 'ABC${kIsWeb ? '' : '\nTab 3 of 3'}', textDirection: TextDirection.ltr, isFocusable: true, isButton: true, + hasEnabledState: true, + hasSelectedState: true, + isEnabled: true, hasTapAction: true, hasFocusAction: true, ), ); }); + testWidgets('Navigation bar disabled semantics', (WidgetTester tester) async { + Widget widget({int selectedIndex = 0}) { + return _buildWidget( + NavigationBar( + selectedIndex: selectedIndex, + destinations: const [ + NavigationDestination(icon: Icon(Icons.ac_unit), label: 'AC', enabled: false), + NavigationDestination(icon: Icon(Icons.ac_unit), label: 'Another'), + ], + ), + ); + } + + await tester.pumpWidget(widget()); + + expect( + tester.getSemantics(find.text('AC')), + matchesSemantics( + label: 'AC${kIsWeb ? '' : '\nTab 1 of 2'}', + textDirection: TextDirection.ltr, + isSelected: true, + hasSelectedState: true, + hasEnabledState: true, + isButton: true, + ), + ); + }); testWidgets('Navigation bar semantics with some labels hidden', (WidgetTester tester) async { Widget widget({int selectedIndex = 0}) { @@ -559,11 +604,14 @@ void main() { expect( tester.getSemantics(find.text('AC')), matchesSemantics( - label: 'AC\nTab 1 of 2', + label: 'AC${kIsWeb ? '' : '\nTab 1 of 2'}', textDirection: TextDirection.ltr, isFocusable: true, isSelected: true, isButton: true, + hasEnabledState: true, + hasSelectedState: true, + isEnabled: true, hasTapAction: true, hasFocusAction: true, ), @@ -571,10 +619,13 @@ void main() { expect( tester.getSemantics(find.text('Alarm')), matchesSemantics( - label: 'Alarm\nTab 2 of 2', + label: 'Alarm${kIsWeb ? '' : '\nTab 2 of 2'}', textDirection: TextDirection.ltr, isFocusable: true, isButton: true, + hasEnabledState: true, + hasSelectedState: true, + isEnabled: true, hasTapAction: true, hasFocusAction: true, ), @@ -585,10 +636,13 @@ void main() { expect( tester.getSemantics(find.text('AC')), matchesSemantics( - label: 'AC\nTab 1 of 2', + label: 'AC${kIsWeb ? '' : '\nTab 1 of 2'}', textDirection: TextDirection.ltr, isFocusable: true, isButton: true, + hasEnabledState: true, + hasSelectedState: true, + isEnabled: true, hasTapAction: true, hasFocusAction: true, ), @@ -596,9 +650,12 @@ void main() { expect( tester.getSemantics(find.text('Alarm')), matchesSemantics( - label: 'Alarm\nTab 2 of 2', + label: 'Alarm${kIsWeb ? '' : '\nTab 2 of 2'}', textDirection: TextDirection.ltr, isFocusable: true, + hasEnabledState: true, + hasSelectedState: true, + isEnabled: true, isSelected: true, isButton: true, hasTapAction: true, diff --git a/packages/flutter/test/material/navigation_drawer_test.dart b/packages/flutter/test/material/navigation_drawer_test.dart index 421df9b305..fde25e676a 100644 --- a/packages/flutter/test/material/navigation_drawer_test.dart +++ b/packages/flutter/test/material/navigation_drawer_test.dart @@ -328,6 +328,7 @@ void main() { textDirection: TextDirection.ltr, isFocusable: true, isSelected: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), @@ -338,6 +339,7 @@ void main() { label: 'Alarm\nTab 2 of 2', textDirection: TextDirection.ltr, isFocusable: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), @@ -351,6 +353,7 @@ void main() { label: 'AC\nTab 1 of 2', textDirection: TextDirection.ltr, isFocusable: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), @@ -362,6 +365,7 @@ void main() { textDirection: TextDirection.ltr, isFocusable: true, isSelected: true, + hasSelectedState: true, hasTapAction: true, hasFocusAction: true, ), diff --git a/packages/flutter/test/material/reorderable_list_test.dart b/packages/flutter/test/material/reorderable_list_test.dart index 8d45aa5bac..9994399ea8 100644 --- a/packages/flutter/test/material/reorderable_list_test.dart +++ b/packages/flutter/test/material/reorderable_list_test.dart @@ -820,6 +820,7 @@ void main() { isEnabled: true, isFocusable: true, hasEnabledState: true, + hasSelectedState: true, label: 'Switch tile', hasTapAction: true, hasFocusAction: true, diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index 3701332299..4372458165 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -690,8 +690,8 @@ Matcher matchesSemantics({ bool isChecked = false, bool isCheckStateMixed = false, bool isSelected = false, - bool isButton = false, bool hasSelectedState = false, + bool isButton = false, bool isSlider = false, bool isKeyboardKey = false, bool isLink = false, @@ -773,6 +773,7 @@ Matcher matchesSemantics({ isChecked: isChecked, isCheckStateMixed: isCheckStateMixed, isSelected: isSelected, + hasSelectedState: hasSelectedState, isButton: isButton, isSlider: isSlider, isKeyboardKey: isKeyboardKey, @@ -883,6 +884,7 @@ Matcher containsSemantics({ bool? isChecked, bool? isCheckStateMixed, bool? isSelected, + bool? hasSelectedState, bool? isButton, bool? isSlider, bool? isKeyboardKey, @@ -965,6 +967,7 @@ Matcher containsSemantics({ isChecked: isChecked, isCheckStateMixed: isCheckStateMixed, isSelected: isSelected, + hasSelectedState: hasSelectedState, isButton: isButton, isSlider: isSlider, isKeyboardKey: isKeyboardKey, @@ -2400,6 +2403,7 @@ class _MatchesSemanticsData extends Matcher { required bool? isChecked, required bool? isCheckStateMixed, required bool? isSelected, + required bool? hasSelectedState, required bool? isButton, required bool? isSlider, required bool? isKeyboardKey, @@ -2459,6 +2463,7 @@ class _MatchesSemanticsData extends Matcher { if (isChecked != null) SemanticsFlag.isChecked: isChecked, if (isCheckStateMixed != null) SemanticsFlag.isCheckStateMixed: isCheckStateMixed, if (isSelected != null) SemanticsFlag.isSelected: isSelected, + if (hasSelectedState != null) SemanticsFlag.hasSelectedState: hasSelectedState, if (isButton != null) SemanticsFlag.isButton: isButton, if (isSlider != null) SemanticsFlag.isSlider: isSlider, if (isKeyboardKey != null) SemanticsFlag.isKeyboardKey: isKeyboardKey, diff --git a/packages/flutter_test/test/matchers_test.dart b/packages/flutter_test/test/matchers_test.dart index ee4f28d6a6..8aba5e9ff4 100644 --- a/packages/flutter_test/test/matchers_test.dart +++ b/packages/flutter_test/test/matchers_test.dart @@ -748,6 +748,7 @@ void main() { hasCheckedState: true, isChecked: true, isCheckStateMixed: true, + hasSelectedState: true, isSelected: true, isButton: true, isSlider: true,