Reputation: 59
When I have a ListView
in GestureDetector
and I override onVerticalDragUpdate
method, the ListView
can't scroll.
How can I both override onVerticalDragUpdate
method so that ListView
remains scrollable?
new GestureDetector(
onVerticalDragUpdate: (details) => print("a"),
child: new ListView(
children: <Widget>[
new Text("a"),
new Text("a"),
new Text("a"),
],
),
)
Upvotes: 1
Views: 2336
Reputation: 6846
If you want to inspect the DragUpdateDetails
, you can wrap the ListView
inside of a 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'),
);
},
),
),
);
}
Upvotes: 1