Reputation: 30879
I have a scrollable widget, say a ListView, which contains some special widget.
How can I prevent the scrollable to scroll when the user tries to scroll by starting to scroll on top of that widget?
In other words, I want that widget to be like a "hole" that prevents the scrollable to sense gestures there.
Upvotes: 22
Views: 7746
Reputation: 32449
If your child is WebView
, GoogleMap
or similar, you can make it to use EagerGestureRecognizer
:
WebView(
...
gestureRecognizers: {
Factory<OneSequenceGestureRecognizer>(
() => EagerGestureRecognizer(),
),
},
),
Upvotes: 1
Reputation: 67
The answer is not satisfying because it prevents the child from receiving gestures (at least on native platforms).
Only acceptable solution I found -- in my case with a PageView -- is to disable the scroll gestures when the page with the gesturedetector child displays.
If anyone has a cleaner solution, please let us know.
Upvotes: 0
Reputation: 909
Wrap the widget with GestureDetector
and implement empty gesture functions in it.
GestureDetector(
onVerticalDragUpdate: (_) {},
child: YourWidget
),
Upvotes: 14