0

Here is an example of using Draggable.

Is there a possibility to get also like the touch coordinate within the Draggable widget? I illustrated what I'm searching for in the image with x1 and x2.

Image - Touch x1 and x2

So I want to determine one of the inner coordinates like x1 or x2.

Here is how I use draggable so far.

draggable = new Draggable(
    data: widget.text,
    feedback: avatar,
    child: item,
    onDraggableCanceled: (velocity, offset) {
      // the inner touch point is not included in offset ...
    },
);

Draggable docs

If it doesn't work with Draggable. Is there an alternative which I can use?

GreenTigerEye
  • 5,917
  • 9
  • 22
  • 33
  • Why do you need to determine the point of interaction? – Shady Aziza Sep 22 '17 at 09:57
  • I do need it because I want to place an image directly to the position where my finger dragged the widget to. So i just need the real position where the touch ended after dragging the widget. – GreenTigerEye Sep 22 '17 at 12:49
  • Do you mean replace the widget that is being dragged with another widget after the drag is completed ? – Shady Aziza Sep 22 '17 at 17:56
  • First i drag to a another position and after releasing my touch a image or widget draws at the position where I released my finger. It is illustrated in this image https://imgur.com/NIYrWlj . After releasing it should look like this https://imgur.com/qvZTdzC – GreenTigerEye Sep 22 '17 at 18:31
  • You can use the OnDraggablecancelled method for that you will get your solution. [Here you will find the implementation of the method](https://docs.flutter.io/flutter/widgets/Draggable/onDraggableCanceled.html) – Aayush Agrawal Jun 15 '18 at 10:36

1 Answers1

0

You can wrap your draggable widget in a Listener and you can do the below code.

onPointerDown: (PointerEvent event) {
            print("Touch Position Of your Widget ${event.position}");
          },