Home > database >  How to know if user stopped dragging outside my widget in Flutter?
How to know if user stopped dragging outside my widget in Flutter?

Time:10-19

GestureDetector(
              onPanDown: (_) => setState(() {
                //start some animation
              }),
              onPanEnd: (_) => setState(
                () {
                 //stop the animation
                 //do a callback ONLY IF the user lifted her finger inside my widget's area
                },
              ),
              child:

I have this GestureDetector and I want to execute a callback only if : the user starts touching the screen inside the gesture detector and starts dragging wherever she wants but she must lift her finger inside the border area of the gesture detector in order for the callback to happen

How can I know if she stops dragging inside my widget and not outside it? The DragEndDetails give the velocity but not the position of the finger/pointer.

CodePudding user response:

Using onTap property instead of onPanDown and onPanEnd solved the issue

  • Related