flutter - 如何检测手势检测器中的向上滑动?
问题描述
我知道有向下滑动检测,onVerticalDragDown
但对于向上滑动检测,小部件中没有onVerticalDragUp
参数GestureDetector
。
解决方案
您正在 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() 一起使用。
推荐阅读
- r - 通过字符变量将一列分成两列
- php - 将使用 FPDF 创建的 pdf 插入/保存到数据库中
- javascript - 有没有办法让 chrome 扩展在标签之间独立运行?
- assembly - 在调用 printf 的循环中与 nasm 中的 mul 相乘 - 结果意外增长
- vb.net - VB.net 中的数据网格视图值
- java - 在 html 的帮助下在 java 中创建一个多色的 JLabel
- ios - 如何阅读符号化的崩溃日志?
- javascript - 上传前压缩文件
- javascript - 如何在 CSS 样式中使用 JavaScript 变量?
- java - 按字段的字段比较两个对象