如何在手势探测器中检测向上滑动?

时间:2020-05-19 07:31:21

标签: flutter dart flutter-layout flutter-dependencies flutter-animation

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

1 个答案:

答案 0 :(得分:1)

您正在寻找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()一起使用。

相关问题