flutter - 如何在不使用 ListView 或 ScrollView 的情况下检测小部件中的滚动?
问题描述
我想检测小部件中的滚动,但我没有使用类似ListView
or的东西GridView
。我试过GestureDetector
这样使用:
void _verticalDragStart(DragStartDetails details) {
started = details.localPosition;
}
void _verticalDragUpdate(DragUpdateDetails details) {
final updatedPosition = details.localPosition;
double difference = started.dy-updatedPosition.dy;
//use difference in my code
}
但由于某种原因,它太快了并且给出了非常高的值。我尝试使用小部件,但如果构建器没有占用比可用空间更多的空间,Scrollable
它不会更新偏移量。Viewport
我能做些什么?
解决方案
我认为您必须查看一个名为 ScrollNotification 的小部件。
希望它有效!
推荐阅读
- android - 将 XML 序列化对象添加到 APK,以便将其复制到应用程序的私有文件目录中
- .net-5 - 捕获任何控制器上的所有异常(甚至处理的异常),以便能够在 1 次通用调用中对它们执行某些操作
- xml - 在 diff-match-patch 中使用 diff 时如何排除日期?
- postgresql - 错误:添加外键 - 在表“X”上插入或更新违反外键约束“FK_X_Y_Z”
- xamarin.forms - Xamarin.Forms 自定义条目渲染器设置条目可在 Android 上滚动
- nlp - 如何在 bertopic 建模中获取每个主题的所有文档
- json - 使用 Rundeck webhook 插件从发布请求中获取数据
- javascript - 如何通过输入值更改 div 边框颜色?
- r - 验证特定列中是否至少有两列具有相同的值
- node.js - 在将字段保存到数据库之前,我应该如何更改字段的值?