Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BouncingScrollPhysics not working with "shrinkWrap: true"

I have a ListView with shrinkWrap: true.

Also, I have applied BouncingScrollPhysics() to the ListView

The problem is bounce physics only works at the bottom of ListView. When I scroll to the top, it doesn't show the bounce effect.

like image 295
Xihuny Avatar asked Jul 20 '19 20:07

Xihuny


Video Answer


4 Answers

You can try this:

SingleChildScrollView(
  physics: BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
  child: Column(...),
)
like image 90
CopsOnRoad Avatar answered Oct 11 '22 20:10

CopsOnRoad


BouncingScrollPhysics() does not always work if the ListView is not 'full'. For example if the ListView needs 5 items to fill its view and become scrollable, then the BouncingScrollPhysics() will probably only work when the ListView contains 5 or more items.

like image 44
Ali Amin Avatar answered Oct 11 '22 19:10

Ali Amin


I had the same problem, I just used physics: AlwaysScrollableScrollPhysics(parent: BouncingScrollPhysics())

like image 37
underfilho Avatar answered Oct 11 '22 19:10

underfilho


Try using NeverScrollableScrollPhysics into the ListView.builder.

But first set the bouncing scroll physics:

child: SingleChildScrollView(
physics: const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),

And in the ListView use both shrinkWrap and physics:

ListView.builder(
shrinkWrap: true, physics: const NeverScrollableScrollPhysics(),
like image 1
Carlos Cuellar Avatar answered Oct 11 '22 20:10

Carlos Cuellar