@@ -101,31 +101,14 @@ final int _kUnblockedUserActions =
101
101
SemanticsAction .didGainAccessibilityFocus.index |
102
102
SemanticsAction .didLoseAccessibilityFocus.index;
103
103
104
- /// Function signature for checks in [DebugSemanticsRoleChecks.kChecks] .
105
- ///
106
- /// The check is run against any `node` that is sent to the platform.
107
- ///
108
- /// To access the flags and properties, one should call the
109
- /// [SemanticsNode.getSemanticsData] .
110
- @visibleForTesting
111
- typedef DebugSemanticsRoleCheck = FlutterError ? Function (SemanticsNode node);
112
-
113
104
/// A static class to conduct semantics role checks.
114
- ///
115
- /// When adding a new [SemanticsRole] , one must also add a corresponding check
116
- /// to [kChecks] .
117
- @visibleForTesting
118
- sealed class DebugSemanticsRoleChecks {
119
- /// A map to map each [SemanticsRole] to its check.
120
- static const Map <SemanticsRole , DebugSemanticsRoleCheck > kChecks =
121
- < SemanticsRole , DebugSemanticsRoleCheck > {
122
- SemanticsRole .none: _noCheckRequired,
123
- SemanticsRole .tab: _semanticsTab,
124
- SemanticsRole .tabBar: _semanticsTabBar,
125
- SemanticsRole .tabPanel: _noCheckRequired,
126
- };
127
-
128
- static FlutterError ? _checkSemanticsData (SemanticsNode node) => kChecks[node.role]! (node);
105
+ sealed class _DebugSemanticsRoleChecks {
106
+ static FlutterError ? _checkSemanticsData (SemanticsNode node) => switch (node.role) {
107
+ SemanticsRole .none => _noCheckRequired,
108
+ SemanticsRole .tab => _semanticsTab,
109
+ SemanticsRole .tabBar => _semanticsTabBar,
110
+ SemanticsRole .tabPanel => _noCheckRequired,
111
+ }(node);
129
112
130
113
static FlutterError ? _noCheckRequired (SemanticsNode node) => null ;
131
114
@@ -3060,7 +3043,7 @@ class SemanticsNode with DiagnosticableTreeMixin {
3060
3043
assert (_dirty);
3061
3044
final SemanticsData data = getSemanticsData ();
3062
3045
assert (() {
3063
- final FlutterError ? error = DebugSemanticsRoleChecks ._checkSemanticsData (this );
3046
+ final FlutterError ? error = _DebugSemanticsRoleChecks ._checkSemanticsData (this );
3064
3047
if (error != null ) {
3065
3048
throw error;
3066
3049
}
0 commit comments