【问题标题】:How to detect swipes up in Gesture Detector? [duplicate]如何检测手势检测器中的向上滑动? [复制]
【发布时间】:2020-09-05 04:35:34
【问题描述】:

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

【问题讨论】:

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


【解决方案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()。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-18
    • 2020-01-17
    • 2016-07-30
    • 1970-01-01
    相关资源
    最近更新 更多