Skip to content

onMoveEnd always called with delta set to Offset.zero #12

@guitoof

Description

@guitoof

Hello,

Thanks for you work on this xgesture_flutter lib. It's really cool to find a wrapper of the Listener widget with a little higher abstraction (I cannot use the GestureDetector or RawGestureDetector widgets in my case because of the GestureArena)

I need to retrieve information about moving gestures like: Distance, Direction, Velocity.
I expected the delta property of the MoveEvent object to hold some information about the distance and direction, but it always seem to be Offset.zero (see screenshot).

image

After a short investigation,onMoveEnd is only called once (L235-236 of gesture_x_detector.dart`) like so:

else if (state == _GestureState.MoveStart) {
      state = _GestureState.Unknown;
      widget.onMoveEnd
          ?.call(MoveEvent(event.localPosition, event.position, event.pointer));

It appears it's called with a MoveEvent object constructed inline here. Looking at the constructor of MoveEvent :

const MoveEvent(
    Offset localPos,
    Offset position,
    int pointer, {
    this.localDelta = const Offset(0, 0),
    this.delta = const Offset(0, 0),
  }) : super(localPos, position, pointer);

It seems that delta (as well as localDelta) is constantly set to Offset.zero... which does not match the corresponding documentation:

 /// Distance in logical pixels that the pointer moved since the last
/// [MoveEvent].

Am I missing something here or is this feature actually not supported yet?
Please let me know if I misunderstood something and this should be working as documented
If not, I should be working on this in the next weeks so I can probably offer a Pull Request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions