flutter - Flutter GestureDetector ListView
问题描述
当我有一个ListView
inGestureDetector
并且我覆盖onVerticalDragUpdate
方法时,ListView
不能滚动。
我如何才能同时覆盖onVerticalDragUpdate
方法以ListView
保持可滚动?
new GestureDetector(
onVerticalDragUpdate: (details) => print("a"),
child: new ListView(
children: <Widget>[
new Text("a"),
new Text("a"),
new Text("a"),
],
),
)
解决方案
如果要检查DragUpdateDetails
,可以ListView
将NotificationListener
.
@override
Widget build(BuildContext context) {
return Scaffold(
body: NotificationListener(
onNotification: (notification) {
if (notification is ScrollUpdateNotification) {
print('${notification.dragDetails}');
}
},
child: ListView.builder(
itemCount: 20,
itemBuilder: (context, index) {
return ListTile(
title: Text('Index = $index'),
);
},
),
),
);
}
推荐阅读
- avro - 如何在另一个 Avro 类型中使用 Avro 类型,而无需再次定义它?
- javascript - 如何在数字的开头添加一个+号,该数字应该不可编辑并与数字一起传递?
- wireguard - Wireguard 端口号
- c++ - 如何将 CPPLINT 集成到 CMake 中并扫描头文件?
- python - 有人可以帮助我使用 Python/IronPython 中的 MQTT 来发布和订阅变量吗?
- microsoft-graph-api - GET https://graph.microsoft.com/v1.0/subscriptions 从不返回结果
- c# - 在 MS Excel 启动时使 IRibbonUI 无效
- kotlin - 在不同节点上的帐户之间转移可替代令牌
- django - django - AttributeError:'AnonymousUser'对象没有属性'todo'
- latex - 停止 Latex \SI 自动将 35 格式化为 3.5 x 10^1