gestureRecognizers property
Which gestures should be forwarded to the PlatformView.
The gesture recognizers built by factories in this set participate in the gesture arena for each pointer that was put down on the widget. If any of these recognizers win the gesture arena, the entire pointer event sequence starting from the pointer down event will be dispatched to the platform view.
When null, an empty set of gesture recognizer factories is used, in which case a pointer event sequence will only be dispatched to the platform view if no other member of the arena claimed it.
For example, with the following setup vertical drags will not be dispatched to the platform view as the vertical drag gesture is claimed by the parent GestureDetector.
GestureDetector(
onVerticalDragStart: (DragStartDetails details) { },
child: PlatformViewSurface(
gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
controller: _controller,
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
),
)
To get the PlatformViewSurface to claim the vertical drag gestures we can pass a vertical drag gesture recognizer factory in gestureRecognizers e.g:
GestureDetector(
onVerticalDragStart: (DragStartDetails details) { },
child: SizedBox(
width: 200.0,
height: 100.0,
child: PlatformViewSurface(
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<OneSequenceGestureRecognizer>(
() => EagerGestureRecognizer(),
),
},
controller: _controller,
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
),
),
)
A platform view can be configured to consume all pointers that were put down in its bounds by passing a factory for an EagerGestureRecognizer in gestureRecognizers. EagerGestureRecognizer is a special gesture recognizer that immediately claims the gesture after a pointer down event.
The gestureRecognizers property must not contain more than one factory with the same Factory.type.
Changing gestureRecognizers results in rejection of any active gesture arenas (if the platform view is actively participating in an arena).
Implementation
// We use OneSequenceGestureRecognizers as they support gesture arena teams.
// TODO(amirh): get a list of GestureRecognizers here.
// https://github.com/flutter/flutter/issues/20953
final Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers;