Flutter – Slivers

Hi Friends,

Hope you are all well. I know it’s been a long time since I posted. I was working on a course for you guys and hence I din’t get time to post new stuff.

So here’s my course – Click here

Other courses on flutter – here. (Affliate link – keeps my site alive by helping me pay for hosting)

A screencast of this post.


In this post let’s try to create a cool ScrollView effect that you might have come across in several apps.

Webp.net-gifmaker (1)

Okay, First of all I am sorry, I made that GIF from a set of screenshots, so it might not be as smooth as one would expect a gif to be.

Anyway, this is a cool effect right? You could display a nice image and when you try to scroll up it automatically transforms into an appbar. This could be easily done in flutter using a CustomScrollView.

Enough talk, let’s get our hands dirty.

As usual, create a new project.

Open up main.dart file and modify it as shown below.

Let’s break this down.

Usually inside a scaffold we specify an appbar and then a body of the app which is essentially what is shown in the screen right ?

Here we are introducing something called a customScrollView and pushing all our content into it. A CustomScrollView helps us to add effects based on the scroll action of the user.

If you notice I am then adding the slivers attribute which is essentially an array of Widgets. We are first introducing a SliverAppBar which is in essence similar to our regular App Bar. The key difference being it gives you more options for customisation. Here I have added the expandedHeight option so that the appBar now covers a larger area of the screen when it is loaded. Then I have brought in an image within the flexibleSpace parameter. The entire image would be shown in the AppBar.

Next I am introducing a SliverList, (This could be a SliverGrid or I could simply fill the remaining space with something). In the sliver list I am simply placing a list of cards. That’s it.

Now let’s run the app and try scrolling.

Webp.net-gifmaker (2)

Wow, it’s even better than we expected right ?

That’s it for now guys. If you found this helpful, kindly share it with someone and help them too.

To learn about bringing in firebase auth and other awesome stuff buy my course – Click here.

Thanks for reading. Peace.. :)

Liked it? Take a second to support admin on Patreon!
  • Wacky

    Thanks for this

    • Cool.. Subscribe to my channel to watch more cool stuff.. I have a whole series of videos on animations coming up..