Skip to content

[super_drag_and_drop] Drag stops working when wrapped in another GestureDetector with drag callbacks #538

@nver-sndk

Description

@nver-sndk

#463 seems to be the change causing our use case to no longer work.

We have a GestureDetecture with onPanStart, onPanUpdate, and onPanEnd. Inside of this, we have a grid of DraggableWidget children.

Expected Behavior

When dragging on top of an actual DraggableWidget, it should consume the gesture and the parent GestureDetector around the whole grid should not handle that gesture, and the item should be dragged.

When dragging outside of a DraggableWidget (i.e. in our case in the space between items in the grid), the parent GestureDetector should receive the gesture events.

(This worked in 0.8.24)

Actual Behavior

As of #463, dragging anywhere in the entire grid gets handled by the parent GestureDetector. This means no items are actually draggable

The only exception to this is when dragging very quickly, the DraggableWidget actually works and drags (presumably because the mouse has already moved >4 pixels and immediately accepts the gesture, before the parent GestureDetector gets a chance to accept it.

Workaround

A very hacky workaround is to replace the parent GestureDetector with a RawGestureDetector, and provide it a custom PanGestureRecognizer like so:

class CustomPanGestureRecognizer extends PanGestureRecognizer {
  @override
  bool hasSufficientGlobalDistanceToAccept(
    PointerDeviceKind pointerDeviceKind,
    double? deviceTouchSlop,
  ) {
    return globalDistanceMoved.abs() > 5;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions