You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make AndroidView participate in gesture arenas. (flutter#20917)
Pointer events are dispatched to the Android view only if it won
Flutter's gesture arena for the pointer.
Specific gestures that should be dispatched to the android view can be
specified with the gestureRecognizers parameter.
Copy file name to clipboardExpand all lines: packages/flutter/lib/src/widgets/platform_view.dart
+32-3Lines changed: 32 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
// found in the LICENSE file.
4
4
5
5
import'package:flutter/foundation.dart';
6
+
import'package:flutter/gestures.dart';
6
7
import'package:flutter/rendering.dart';
7
8
import'package:flutter/services.dart';
8
9
@@ -21,6 +22,12 @@ import 'framework.dart';
21
22
/// The widget fill all available space, the parent of this object must provide bounded layout
22
23
/// constraints.
23
24
///
25
+
/// AndroidView participates in Flutter's [GestureArena]s, and dispatches touch events to the
26
+
/// Android view iff it won the arena. Specific gestures that should be dispatched to the Android
27
+
/// view can be specified in [AndroidView.gestureRecognizers]. If
28
+
/// [AndroidView.gestureRecognizers] is empty, the gesture will be dispatched to the Android
29
+
/// view iff it was not claimed by any other gesture recognizer.
30
+
///
24
31
/// The Android view object is created using a [PlatformViewFactory](/javadoc/io/flutter/plugin/platform/PlatformViewFactory.html).
25
32
/// Plugins can register platform view factories with [PlatformViewRegistry#registerViewFactory](/javadoc/io/flutter/plugin/platform/PlatformViewRegistry.html#registerViewFactory-java.lang.String-io.flutter.plugin.platform.PlatformViewFactory-).
26
33
///
@@ -41,18 +48,20 @@ import 'framework.dart';
41
48
classAndroidViewextendsStatefulWidget {
42
49
/// Creates a widget that embeds an Android view.
43
50
///
44
-
/// The `viewType`and `hitTestBehavior` parameters must not be null.
51
+
/// The `viewType`, `hitTestBehavior`, and `gestureRecognizers` parameters must not be null.
45
52
/// If `creationParams` is not null then `creationParamsCodec` must not be null.
/// Passed as the args argument of [PlatformViewFactory#create](/javadoc/io/flutter/plugin/platform/PlatformViewFactory.html#create-android.content.Context-int-java.lang.Object-)
82
102
///
83
103
/// This can be used by plugins to pass constructor parameters to the embedded Android view.
@@ -105,7 +125,8 @@ class _AndroidViewState extends State<AndroidView> {
105
125
Widgetbuild(BuildContext context) {
106
126
returnnew_AndroidPlatformView(
107
127
controller: _controller,
108
-
hitTestBehavior: widget.hitTestBehavior
128
+
hitTestBehavior: widget.hitTestBehavior,
129
+
gestureRecognizers: widget.gestureRecognizers,
109
130
);
110
131
}
111
132
@@ -182,20 +203,28 @@ class _AndroidPlatformView extends LeafRenderObjectWidget {
0 commit comments