首页 > 解决方案 > 如何检测手势检测器中的向上滑动?

问题描述

我知道有向下滑动检测,onVerticalDragDown但对于向上滑动检测,小部件中没有onVerticalDragUp参数GestureDetector

标签: flutterdartflutter-layoutflutter-dependenciesflutter-animation

解决方案


您正在 GestureDetector 类中寻找onPanUpdate方法。

GestureDetector(onPanUpdate: (details) {
  if (details.delta.dx > 0)
    print("Dragging in +X direction");
  else
    print("Dragging in -X direction");

  if (details.delta.dy > 0)
    print("Dragging in +Y direction");
  else
    print("Dragging in -Y direction");
});

注意:不要将此方法与您已经使用的方法 (onVerticalDragDown) 或 onVerticalDragUpdate() 一起使用。


推荐阅读