text
stringlengths
1
372
without hurting scrolling performance?
do you set the ShrinkWrap property to true,
or do you use a sliver?
check out the “shrinkwrap vs slivers” video:
<topic_end>
<topic_start>
using slivers to achieve fancy scrolling
a sliver is a portion of a scrollable area that you
can define to behave in a special way.
you can use slivers to achieve custom scrolling effects,
such as elastic scrolling.
for a free, instructor-led video workshop that uses DartPad,
check out the following video about using slivers.
<topic_end>
<topic_start>
resources
for more information on implementing fancy scrolling effects
in flutter, see the following resources:
a free article on medium that
explains how to implement custom scrolling
using the sliver classes.
a one-minute widget-of-the-week
video that gives an overview of the
SliverAppBar widget.
a one-minute widget-of-the-week
video that gives an overview of the SliverList
and SliverGrid widgets.
a 50-minute episode of the boring show
where ian hickson, flutter’s tech lead, and filip hracek
discuss the power of slivers.
<topic_end>
<topic_start>
API docs
to learn more about the available sliver APIs,
check out these related API docs:
<topic_end>
<topic_start>
place a floating app bar above a list
to make it easier for users to view a list of items,
you might want to hide the app bar as the user scrolls down the list.
this is especially true if your app displays a “tall”
app bar that occupies a lot of vertical space.
typically, you create an app bar by providing an appBar property to the
scaffold widget. this creates a fixed app bar that always remains above
the body of the scaffold.
moving the app bar from a scaffold widget into a
CustomScrollView allows you to create an app bar
that scrolls offscreen as you scroll through a
list of items contained inside the CustomScrollView.
this recipe demonstrates how to use a CustomScrollView to display a list of
items with an app bar on top that scrolls offscreen as the user scrolls
down the list using the following steps:
<topic_end>
<topic_start>
1. create a CustomScrollView
to create a floating app bar, place the app bar inside a
CustomScrollView that also contains the list of items.
this synchronizes the scroll position of the app bar and the list of items.
you might think of the CustomScrollView widget as a ListView
that allows you to mix and match different types of scrollable lists
and widgets together.
the scrollable lists and widgets provided to the
CustomScrollView are known as slivers. there are several types
of slivers, such as SliverList, SliverGrid, and SliverAppBar.
in fact, the ListView and GridView widgets use the SliverList and
SliverGrid widgets to implement scrolling.
for this example, create a CustomScrollView that contains a
SliverAppBar and a SliverList. in addition, remove any app bars
that you provide to the scaffold widget.
<code_start>
scaffold(
// no appBar property provided, only the body.
body: CustomScrollView(
// add the app bar and list of items as slivers in the next steps.
slivers: <widget>[]),
);
<code_end>
<topic_end>
<topic_start>
2. use SliverAppBar to add a floating app bar
next, add an app bar to the CustomScrollView.
flutter provides the SliverAppBar widget which,
much like the normal AppBar widget,
uses the SliverAppBar to display a title,
tabs, images and more.
however, the SliverAppBar also gives you the ability to create a “floating”
app bar that scrolls offscreen as the user scrolls down the list.
furthermore, you can configure the SliverAppBar to shrink and
expand as the user scrolls.
to create this effect:
<code_start>
CustomScrollView(
slivers: [
// add the app bar to the CustomScrollView.
const SliverAppBar(
// provide a standard title.
title: text(title),
// allows the user to reveal the app bar if they begin scrolling
// back up the list of items.
floating: true,