Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add ScrollController to SliverList flutter

Tags:

flutter

dart

I can add ScrollController to a ListView. I was trying to do the same for SliverList but I realized there is no parameter to add a controller. Is there any other way I can achieve this? Thank you.

like image 250
nivla360 Avatar asked Jun 15 '20 13:06

nivla360


People also ask

How do you use a SliverList in flutter?

Dart. The SliverStack() allows putting one sliver on another. In the below example, through SliverPositioned() we are creating the complete layout of yellow color on top of which we are rendering list items using SliverList(). SliverList() takes a delegate as a parameter to give the items to the list to be scrolled.

How do you use custom scroll view in flutter?

Now lets start implementation of CustomScrollView in Flutter First of all, create a basic project and return a Custom Scroll View widget. Then, add a silver app bar and then add a silver grid. Here we only used two child widgets in the custom scroll view. The Entry point of code.

What is ScrollController in flutter?

A scroll controller creates a ScrollPosition to manage the state specific to an individual Scrollable widget. To use a custom ScrollPosition, subclass ScrollController and override createScrollPosition. A ScrollController is a Listenable.

What is SliverFixedExtentList?

SliverFixedExtentList class Null safety. A sliver that places multiple box children with the same main axis extent in a linear array. SliverFixedExtentList places its children in a linear array along the main axis starting at offset zero and without gaps.


1 Answers

You cannot add it to a SliverList, you can however, add the controller to your parent CustomScrollView. The SliverList comes inside the CustomScrollView and should give you the effect you want. As you can see in the screenshot, you can add a controller to your CustomScrollView

like image 61
AbdulAziz Umar Avatar answered Oct 31 '22 09:10

AbdulAziz Umar