首页 > 解决方案 > Get notification when user pauses dragging

问题描述

is there a way to get notified when user stops dragging over the screen (using GestureDetector) when the finger is still on the screen? After lifting the finger I do get DragEndDetails event. What I need is sort of "user paused scrolling". Current behaviour is: while moving the finger I do get DragUpdateDetails but when I stop dragging (finger on the screen, drag velocity is 0) neither DragUpdateDetails nor DragEndDetails are fired.

Cheers.

标签: flutter

解决方案


当您收到拖动更新事件时,您可以设置一个计时器(例如 1 秒)。

如果在此期间没有发生拖动更新(或仅发生最小拖动),则触发您的回调。否则,如果有明显的移动,重新启动计时器...

当拖动被取消或手指被移除或小部件被释放时,取消定时器。


推荐阅读