gestureRecognizers property Null safety

Set<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers
final

Which gestures should be forwarded to the UIKit view.

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 UIKit view as the vertical drag gesture is claimed by the parent GestureDetector.

GestureDetector(
  onVerticalDragStart: (DragStartDetails details) {},
  child: UiKitView(
    viewType: 'webview',
  ),
)

To get the UiKitView 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: UiKitView(
      viewType: 'webview',
      gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
        new Factory<OneSequenceGestureRecognizer>(
          () => new EagerGestureRecognizer(),
        ),
      ].toSet(),
    ),
  ),
)

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;