Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Flutter, how can a child widget prevent the scrolling of its scrollable parent?

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.

like image 960
MarcG Avatar asked Feb 28 '19 15:02

MarcG


People also ask

How do I stop a widget from scrolling in Flutter?

Flutter ListView – Never Scrollable You can make the ListView widget never scrollable by setting physics property to NeverScrollableScrollPhysics().

How do I stop my widgets from scrolling?

Use physics: const NeverScrollableScrollPhysics() in Listview Then you can prevent your widget from beeing scrolled.

How do I stop the scroll of GridView Flutter?

You can provide physics: NeverScrollableScrollPhysics() on GridView to disable scroll effect. If you want scrollable as secondary widget use primary: false, To have Full Page scrollable, you can use body:SingleChildScrollView(..) or better using body:CustomScrollView(..) Save this answer.

How do you limit scrolls in Flutter?

You need to add a padding to your ListView in order to offset the scroll boundary into the screen.


1 Answers

Wrap the widget with GestureDetector and implement empty gesture functions in it.

GestureDetector(
   onVerticalDragUpdate: (_) {},
   child: YourWidget
),
like image 124
Willy Avatar answered Oct 11 '22 13:10

Willy