Reputation: 13803
In a page, my listView can be scrolled if I have at least 7 items or more. if there are only 3 items in my list then listView can not be scrolled.
I need to show Refresh Indicator (that circular indicator at the top of list) in my list even though I have less than 7 items (list can not be scrolled). How to do that?
Here is my code:
return RefreshIndicator(
onRefresh: () {},
child: ListView.builder(
physics: ClampingScrollPhysics(),
itemCount: controller.items.length + 1,
itemBuilder: (context, index) {
},
}
)
Upvotes: 1
Views: 1380
Reputation: 12565
As well as you can wrap your Listview
, you can change this behavior so that the ListView
only occupies the space it needs
return RefreshIndicator(
onRefresh: () {},
child: ListView.builder(
shrinkWrap: true,
physics: ScrollPhysics(),
itemCount: controller.items.length + 1,
itemBuilder: (context, index) {
},
}
)
Upvotes: -1
Reputation: 1500
You can do this if you don't wanna lose your clamping physics:
physics: ClampingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
Upvotes: 6
Reputation: 891
set the physics
of the listView to AlwaysScrollableScrollPhysics()
return RefreshIndicator(
onRefresh: () {},
child: ListView.builder(
physics: AlwaysScrollableScrollPhysics(),
itemCount: controller.items.length + 1,
itemBuilder: (context, index) {
},
}
)
Upvotes: 3