PointerSignalResolver class

Mediates disputes over which listener should handle pointer signal events when multiple listeners wish to handle those events.

Pointer signals (such as PointerScrollEvent) are immediate, so unlike events that participate in the gesture arena, pointer signals always resolve at the end of event dispatch. Yet if objects interested in handling these signal events were to handle them directly, it would cause issues such as multiple Scrollable widgets in the widget hierarchy responding to the same mouse wheel event. Using this class, these events will only be dispatched to the first registered handler, which will in turn correspond to the widget that's deepest in the widget hierarchy.

To use this class, objects should register their event handler like so:

void handleSignalEvent(PointerSignalEvent event) {
  GestureBinding.instance.pointerSignalResolver.register(event, (PointerSignalEvent event) {
    // handle the event...
  });
}

Here is an example that demonstrates the effect of not using the resolver versus using it.

When this example is set to not use the resolver, then triggering the mouse wheel over the outer box will cause only the outer box to change color, but triggering the mouse wheel over the inner box will cause both the outer and the inner boxes to change color (because they're both receiving the event).

When this example is set to use the resolver, then only the box located directly under the cursor will change color when the mouse wheel is triggered.

link

To create a local project with this code sample, run:
flutter create --sample=gestures.PointerSignalResolver.1 mysample

Constructors

PointerSignalResolver()

Properties

hashCode int
The hash code for this object.
no setterinherited
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
register(PointerSignalEvent event, PointerSignalResolvedCallback callback) → void
Registers interest in handling event.
resolve(PointerSignalEvent event) → void
Resolves the event, calling the first registered callback if there was one.
toString() String
A string representation of this object.
inherited

Operators

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