主要是要分两个状态进行判断
Listener(
onPointerUp: (PointerUpEvent event) {
//手指放开屏幕
projectDetailController.setPointerDownStatue(false);
},
onPointerMove: (PointerMoveEvent event) {
//手指一直按住屏幕
projectDetailController.setPointerDownStatue(true);
},
onPointerDown: (PointerDownEvent event) {
//手指按下屏幕
projectDetailController.setPointerDownStatue(true);
},
child: NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification notification) {
if (notification is ScrollStartNotification) {
//手指一直在屏幕上且处于滑动中 再判断处于滑动状态
if (projectDetailController.isPointerDown.isTrue) {
projectDetailController.setScolling(true);
}
} else if (notification is ScrollEndNotification) {
projectDetailController.setScolling(false);
}
return false;
},
child: Container(),
),
)
flutter 检测 滑动开始 和滑动停止
最新推荐文章于 2024-08-25 16:38:39 发布