Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable ListView Scroll

Is possible to disable ListView Scroll if page don't overflow the screen size?

I always use ListView to avoid overflow the screen, but when the content of the page is smaller than screen I can see the end scroll animation, how can i disable the scroll in this cases, and able to scroll if the screen size is small??

like image 436
pksasso Avatar asked Jul 29 '19 01:07

pksasso


People also ask

How do I disable scrolling in list view?

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

Is ListView scrollable by default?

ListView itself is scrollable.

How do I stop GridView scrolling in flutter?

You can provide physics: NeverScrollableScrollPhysics() on GridView to disable scroll effect.


1 Answers

You can set the scroll physics property on the ListView, which will disable scrolling:

shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),

You can also switch between enabling or disabling scrolling at runtime if you have to via some condition like so:

shrinkWrap: true,
physics: disableScrolling ? NeverScrollableScrollPhysics() : 
         AlwaysScrollableScrollPhysics(),
like image 152
spenster Avatar answered Oct 17 '22 15:10

spenster