1. The Problem
How do I make my ListView.builder
be able to scroll to empty space both to the top and to the bottom?
For example, I have a list of custom widgets, and I would like the user to be able to get the top card on the list — which is at the top of the screen — closer to his thumb by scrolling to it, while Flutter
renders the top space with an empty background.
2. What I've tried so far
The basic shape of my code is a basic implementation of the ListView.builder
constructor:
ListView.builder(
itemCount: widgetsList.length,
itemBuilder: (context, index){
return widgetsList[index];
},
),
I've tried fiddling with some of the ListView.builder
's properties and also some workarounds so far:
- At first, I thought that either
shrinkWrap: true
orphysics: AlwaysScrollableScrollPhysics()
— maybe I have to set theparent
parameter ofAlwaysScrollableScrollPhysics()
? — would do the job, but none of them seem to work. - I've also tried to do this artifially by creating empty
Container
s both on the top and the bottom of the list, and adding something likedragStartBehavior: DragStartBehavior.values[1]
— I don't think that's how you use the.values
property actually — to make the list start from the second value, but it didn't work.