Adds semantics role and adjust semantics for navigation bar (#162467)

<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

framework side of https://github.com/flutter/flutter/issues/107861

## 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
This commit is contained in:
chunhtai
2025-04-02 14:28:56 -07:00
committed by GitHub
parent 34ea67bdbf
commit aeab137280
13 changed files with 196 additions and 59 deletions

View File

@@ -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: <Widget>[
for (int i = 0; i < destinations.length; i++)
Expanded(
child: _SelectableAnimatedBuilder(
duration: animationDuration ?? const Duration(milliseconds: 500),
isSelected: i == selectedIndex,
builder: (BuildContext context, Animation<double> 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: <Widget>[
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<double> 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: <Widget>[
child,
Semantics(
label: localizations.tabLabel(
tabIndex: destinationInfo.index + 1,
tabCount: destinationInfo.totalNumberOfDestinations,
),
),
],
),
child:
kIsWeb
? child
: Stack(
alignment: Alignment.center,
children: <Widget>[
child,
Semantics(
label: localizations.tabLabel(
tabIndex: destinationInfo.index + 1,
tabCount: destinationInfo.totalNumberOfDestinations,
),
),
],
),
);
}
}

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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,
),

View File

@@ -1232,6 +1232,7 @@ void main() {
isChecked: true,
hasEnabledState: true,
isEnabled: true,
hasSelectedState: true,
hasTapAction: true,
hasFocusAction: true,
isFocusable: true,

View File

@@ -1714,6 +1714,7 @@ void main() {
label: '3, Sunday, January 3, 2016, Today',
isButton: true,
hasTapAction: true,
hasSelectedState: true,
hasFocusAction: true,
isFocusable: true,
),

View File

@@ -1471,6 +1471,7 @@ void main() {
label: '30, Saturday, January 30, 2016, Today',
hasTapAction: true,
hasFocusAction: true,
hasSelectedState: true,
isFocusable: true,
),
);

View File

@@ -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',

View File

@@ -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 <Widget>[
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,

View File

@@ -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,
),

View File

@@ -820,6 +820,7 @@ void main() {
isEnabled: true,
isFocusable: true,
hasEnabledState: true,
hasSelectedState: true,
label: 'Switch tile',
hasTapAction: true,
hasFocusAction: true,

View File

@@ -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,

View File

@@ -748,6 +748,7 @@ void main() {
hasCheckedState: true,
isChecked: true,
isCheckStateMixed: true,
hasSelectedState: true,
isSelected: true,
isButton: true,
isSlider: true,