F.SO7
F.SO7

Reputation: 925

Flutter ListView bounces at the bottom but not on the top (iOS)

I have an app that contains a Widget which presents a ListView.builder with some custom Widgets in it (dynamic length).

For some reason, the list bounces perfectly fine on the bottom (over-scroll in the bottom), but does not bonce at the top (on over-scroll in the top).

I've tried to add this line of code:

physics: AlwaysScrollableScrollPhysics( parent: BouncingScrollPhysics() ),

as well as this one:

physics: BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics() ),

But none of them worked.

Does anyone know how can I make the list bounce on both sides?

Upvotes: 2

Views: 2274

Answers (2)

Michael Olusegun
Michael Olusegun

Reputation: 815

The top doesn't bounce because you set the shrinkWrap property of the listview to true.

Solution: set shrinkWrap to false and wrap your listView with a container() or sizedBox()

Check the video below for illustration.

https://drive.google.com/file/d/1_f1d0iY0XVOFi2RoCgbohk4CRhT0G08_/view?usp=sharing

Upvotes: 5

iDecode
iDecode

Reputation: 28916

Without actually seeing your code, it seems like you're using shrinkWrap: true property in your ListView which is preventing it to overscroll on the top (bottom works though).

If that's the case, your better bet is to use a Column wrapped in a SingleChildScrollView. Here's the minimal code:

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

Upvotes: 2

Related Questions