当我在GestureDetector中有一个ListView,并且我覆盖了onVerticalDragUpdate方法时,ListView不能滚动。
如何才能重写onVerticalDragUpdate方法以使ListView保持可滚动?
new GestureDetector(
onVerticalDragUpdate: (details) => print("a"),
child: new ListView(
children: <Widget>[
new Text("a"),
new Text("a"),
new Text("a"),
],
),
)发布于 2019-01-23 00:12:11
如果要检查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'),
);
},
),
),
);
}https://stackoverflow.com/questions/54306547
复制相似问题