UiKitViewGestureBlockingPolicy enum

How touch event callbacks and gesture recognizers of a platform view are blocked.

This replaces the engine's FlutterPlatformViewGestureRecognizersBlockingPolicy enum in FlutterPlugin.h.

In iOS, a gesture recognizer (UIGestureRecognizer) is an object that decouples the logic for recognizing a sequence of touches (like a tap, pinch, or swipe) and acting on that recognition.

When a Flutter app embeds an iOS platform view (like a WKWebView), both the Flutter framework and the native iOS view receive touch events. To prevent both systems from simultaneously reacting to the same touch (e.g., a scroll gesture scrolling both a Flutter ListView and a native UIScrollView), Flutter needs a mechanism to "block" the native view's gesture recognizers when it determines that the Flutter framework should handle the gesture.

Flutter uses two mechanisms to achieve this:

  1. Synchronous Blocking (Hit Testing): During the initial touch (UIResponder.touchesBegan), Flutter performs a synchronous hit test. If the touch lands on a Flutter widget that is visually on top of the platform view, Flutter immediately blocks the native view from receiving the touch.
  2. Asynchronous Blocking (Gesture Arena): If the touch lands directly on the platform view, both Flutter and the native view begin tracking the gesture. Flutter's gesture arena resolves which system wins. If Flutter wins (e.g., the user is scrolling a Flutter ListView that contains the platform view), Flutter asynchronously cancels the native view's gesture recognizers.

The default policy (fallbackToPluginDefault, which typically resolves to eager) works for most use cases. However, some native views (either from Apple or 3rd party) may have bugs where their internal gesture recognizers get stuck in a stale state if they are aggressively canceled by Flutter's asynchronous blocking. In these specific cases, you might need to change the policy to doNotBlockGesture or waitUntilTouchesEnded to work around the native view's bugs.

For more details, see: https://flutter.dev/go/ios-platform-view-touch-gesture-blocking.

Inheritance
Available extensions

Values

eager → const UiKitViewGestureBlockingPolicy

Flutter blocks all the UIGestureRecognizers on the platform view as soon as it decides they should be blocked.

This policy employs a dual blocking strategy: synchronous blocking via hitTest results and asynchronous blocking managed through the framework’s gesture arena. With this policy, only the touchesBegan method for all the UIGestureRecognizers is guaranteed to be called.

waitUntilTouchesEnded → const UiKitViewGestureBlockingPolicy

Flutter blocks all the UIGestureRecognizers on the platform view only after touchesEnded was invoked.

This results in the platform view's UIGestureRecognizers seeing the entire touch sequence, but never recognizing the gesture (and never invoking actions). Using this policy may cause the platform view to incorrectly receive touch events that should have been blocked.

doNotBlockGesture → const UiKitViewGestureBlockingPolicy

Causes iOS engine to block all the UIGestureRecognizers on the platform view if it deems the hittest shouldn't be handled by the Flutter framework.

Unlike eager, this policy does not rely on Flutter's gesture arena. This is a workaround to address a few bugs related to platform view's gesture recognizers being stuck in a stale state. See: https://github.com/flutter/flutter/issues/175099. Using this policy may cause the platform view to incorrectly recognize a gesture that should have been blocked.

fallbackToPluginDefault → const UiKitViewGestureBlockingPolicy

Fallback to use the policy set by the registerViewFactory engine API in FlutterPlugin.h.

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
name String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

values → const List<UiKitViewGestureBlockingPolicy>
A constant List of the values in this enum, in order of their declaration.