@@ -12,33 +12,30 @@ class MyApp extends StatelessWidget {
12
12
return MaterialApp (
13
13
title: title,
14
14
home: Scaffold (
15
- // No appbar provided to the Scaffold, only a body with a
15
+ // No app bar provided to Scaffold, only a body with a
16
16
// CustomScrollView.
17
17
body: CustomScrollView (
18
18
slivers: [
19
19
// Add the app bar to the CustomScrollView.
20
20
const SliverAppBar (
21
21
// Provide a standard title.
22
22
title: Text (title),
23
- // Allows the user to reveal the app bar if they begin scrolling
24
- // back up the list of items.
25
- floating: true ,
23
+ // Pin the app bar when scrolling
24
+ pinned: true ,
26
25
// Display a placeholder widget to visualize the shrinking size.
27
26
flexibleSpace: Placeholder (),
28
27
// Make the initial height of the SliverAppBar larger than normal.
29
28
expandedHeight: 200 ,
30
29
),
31
30
// #docregion SliverList
32
31
// Next, create a SliverList
33
- SliverList (
34
- // Use a delegate to build items as they're scrolled on screen.
35
- delegate: SliverChildBuilderDelegate (
36
- // The builder function returns a ListTile with a title that
37
- // displays the index of the current item.
38
- (context, index) => ListTile (title: Text ('Item #$index ' )),
39
- // Builds 1000 ListTiles
40
- childCount: 1000 ,
41
- ),
32
+ SliverList .builder (
33
+ // The builder function returns a ListTile with a title that
34
+ // displays the index of the current item.
35
+ itemBuilder:
36
+ (context, index) => ListTile (title: Text ('Item #$index ' )),
37
+ // Builds 50 ListTiles
38
+ itemCount: 50 ,
42
39
),
43
40
// #enddocregion SliverList
44
41
],
0 commit comments