How do I make my ListView.builder
be able to scroll to empty space both to the top and to the bottom?
For example,
That is possible to be achived with your "Container
workaround". You could use a ScrollController
and have its initialScrollOffset
where the top Container
ends. It is something I only later found out through this other StackOverflow question.
ScrollController
inside your widget's class.
ScrollController scrollController = ScrollController(
initialScrollOffset: 10, // or whatever offset you wish
keepScrollOffset: true,
);
ListView
ListView.builder(
controller: scrollController,
itemCount: widgetsList.length,
itemBuilder: (context, index){
return widgetsList[index];
},
),
Additionally, you may even want to create animations for the background scrolling action. That is possible through using the .animateTo
method inside your widget's initState
.