Introduction
Hi friends!! Do you want to create complex and modern UI designs in Flutter? If yes, then this article is surely good for you. The sliver widget is one of the advanced concepts in Flutter and it provides smooth and fancy scrolling experience for your Flutter app. Sliver widgets are designed to work seamlessly with the CustomScrollView widget. Please always make sure that any sliver widget is used inside CustomScrollView. The Sliver widget is beneficial when we need to display multiple lists on the screen, and the requirement is for the entire page to scroll as one unit instead of individual lists scrolling separately.
Prerequisite
- Basic knowledge of Flutter
- Having the latest version of Android Studio
In Flutter, there are several Sliver widgets, but the most common and frequently used widget are as follow.
- SliverAppBar
- SliverToBoxAdapter
- SliverList
- SliverGrid
SliverAppBar Widget in Flutter
In Flutter, SliverAppBar is a special widget that provides a collapsible app bar that can be used within a CustomScrollView. It's commonly used to create a flexible app bar that can expand and contract as the user scrolls through content.
Important Properties In SliverAppBar Widget.
- expandedHeight: This property defines the height of the app bar when it's fully expanded. As you scroll, the app bar will shrink from this height down to its regular size.
- floating: When floating is set to true, the app bar can "float" above the content as the user scrolls down. This means that when the user scrolls back up, the app bar will quickly snap back to its full height. This behavior is useful for providing quick access to app bar actions.
- pinned: When pinned set to true, the app bar will remain pinned at the top of the screen even as the user scrolls.
- snap: If both floating and pinned are true, the app bar snaps to fully opened or fully collapsed when scrolling.
- flexibleSpace: This property allows you to define the flexible content that appears within the app bar as it expands and collapses.
- title: The title displayed in the app bar when it's fully expanded.
- actions: A list of widgets that represent actions or icons to be displayed in the app bar. These are often used for actions like searches, settings, or user profiles.
Example
CustomScrollView(
slivers: [
SliverAppBar(
expandedHeight: 200.0, // Max height when fully expanded
floating: true, // Doesn't float above content
pinned: true, // Stays pinned to the top
flexibleSpace: FlexibleSpaceBar(
title: Text("Flutter News"), // Title when fully expanded
background: Image.network(
"https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250",
fit: BoxFit.fill,
),
),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
// Build your news article content here
return ListTile(
title: Text("News Headline $index"),
subtitle: Text("Author Name"),
);
},
childCount: 20, // Number of news articles
),
),
],
),
Output
SliverToBoxAdapter Widget in Flutter
This widget is really good because it allows adding of non-sliver widgets inside the CustomScrollView widget. Using this widget, we can add widgets such as ListView, Text, Row, Column, etc., inside the CustomScrollView widget.
Example

Join the conversation! Your thoughts help the community grow.