2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
- import 'dart:ui' as ui show AccessibilityFeatures, SemanticsAction , SemanticsUpdateBuilder;
5
+ import 'dart:ui' as ui show AccessibilityFeatures, SemanticsActionEvent , SemanticsUpdateBuilder;
6
6
7
7
import 'package:flutter/foundation.dart' ;
8
8
import 'package:flutter/services.dart' ;
9
9
10
10
import 'debug.dart' ;
11
11
12
- export 'dart:ui' show AccessibilityFeatures, SemanticsUpdateBuilder;
12
+ export 'dart:ui' show AccessibilityFeatures, SemanticsActionEvent, SemanticsUpdateBuilder;
13
13
14
14
/// The glue between the semantics layer and the Flutter engine.
15
15
mixin SemanticsBinding on BindingBase {
@@ -20,7 +20,7 @@ mixin SemanticsBinding on BindingBase {
20
20
_accessibilityFeatures = platformDispatcher.accessibilityFeatures;
21
21
platformDispatcher
22
22
..onSemanticsEnabledChanged = _handleSemanticsEnabledChanged
23
- ..onSemanticsAction = _handleSemanticsAction
23
+ ..onSemanticsActionEvent = _handleSemanticsActionEvent
24
24
..onAccessibilityFeaturesChanged = handleAccessibilityFeaturesChanged;
25
25
_handleSemanticsEnabledChanged ();
26
26
}
@@ -111,12 +111,12 @@ mixin SemanticsBinding on BindingBase {
111
111
}
112
112
}
113
113
114
- void _handleSemanticsAction ( int id, ui.SemanticsAction action, ByteData ? args ) {
115
- performSemanticsAction ( SemanticsActionEvent (
116
- nodeId : id,
117
- type : action,
118
- arguments : args != null ? const StandardMessageCodec (). decodeMessage (args) : null ,
119
- ) );
114
+ void _handleSemanticsActionEvent ( ui.SemanticsActionEvent action) {
115
+ final Object ? arguments = action.arguments;
116
+ final ui. SemanticsActionEvent decodedAction = arguments is ByteData
117
+ ? action. copyWith (arguments : const StandardMessageCodec (). decodeMessage (arguments))
118
+ : action;
119
+ performSemanticsAction (decodedAction );
120
120
}
121
121
122
122
/// Called whenever the platform requests an action to be performed on a
@@ -130,9 +130,9 @@ mixin SemanticsBinding on BindingBase {
130
130
/// perform the given `action` on the [SemanticsNode] specified by
131
131
/// [SemanticsActionEvent.nodeId] .
132
132
///
133
- /// See [dart:ui.PlatformDispatcher.onSemanticsAction ] .
133
+ /// See [dart:ui.PlatformDispatcher.onSemanticsActionEvent ] .
134
134
@protected
135
- void performSemanticsAction (SemanticsActionEvent action);
135
+ void performSemanticsAction (ui. SemanticsActionEvent action);
136
136
137
137
/// The currently active set of [AccessibilityFeatures] .
138
138
///
@@ -180,27 +180,6 @@ mixin SemanticsBinding on BindingBase {
180
180
}
181
181
}
182
182
183
- /// An event to request a [SemanticsAction] of [type] to be performed on the
184
- /// [SemanticsNode] identified by [nodeId] .
185
- ///
186
- /// Used by [SemanticsBinding.performSemanticsAction] .
187
- @immutable
188
- class SemanticsActionEvent {
189
- /// Creates a [SemanticsActionEvent] .
190
- ///
191
- /// The [type] and [nodeId] are required.
192
- const SemanticsActionEvent ({required this .type, required this .nodeId, this .arguments});
193
-
194
- /// The type of action to be performed.
195
- final ui.SemanticsAction type;
196
-
197
- /// The id of the [SemanticsNode] on which the action is to be performed.
198
- final int nodeId;
199
-
200
- /// Optional arguments for the action.
201
- final Object ? arguments;
202
- }
203
-
204
183
/// A reference to the semantics information generated by the framework.
205
184
///
206
185
/// Semantics information are only collected when there are clients interested
0 commit comments