cs guy
cs guy

Reputation: 939

Flutter How to detect pointer swiping along multiple containers

Lets say I have two containers placed differently below here. User starts swiping continuously from the bottom end of the arrow until the top. I want to be able to detect the following actions: OnPointerEnteredYellow, OnPointerExitedYellow, OnPointerEnteredRed, OnPointerExitedRed.

I tried GestureDetector:

GestureDetector(
      onPanUpdate: (update) {
        print(update);
      },
      child: Container(
        color: Colors.red,
        height: 300,
        width: 400,
      ),
    );

If I start the drag from outside the container and swipe into the container, it does not detect my swipe. I want to detect this swipe. How may I do that?

A very good example

Upvotes: 1

Views: 322

Answers (1)

Azad Prajapat
Azad Prajapat

Reputation: 806

Hi Dear you can try the following algorithm which i think give you your required result. Add the gesture detector at top and then you have the pan details wherever your pointer will be now for yellow circle you will surely now the offset of center and radius of circle then check weather distance from the center of circle to the pointer is less or greater then radius of r . similarly you can do for other circle. just playaround this method you will surely get your result. thanks

Upvotes: 1

Related Questions