File tree 7 files changed +323
-66
lines changed
examples/cookbook/lists/floating_app_bar/lib
src/content/cookbook/lists
7 files changed +323
-66
lines changed Original file line number Diff line number Diff line change
1
+ import 'package:flutter/cupertino.dart' ;
2
+
3
+ void main () => runApp (const MyApp ());
4
+
5
+ class MyApp extends StatelessWidget {
6
+ const MyApp ({super .key});
7
+
8
+ @override
9
+ Widget build (BuildContext context) {
10
+ const title = 'Floating Navigation Bar' ;
11
+
12
+ return CupertinoApp (
13
+ title: title,
14
+ home: CupertinoPageScaffold (
15
+ // No navigation bar provided to CupertinoPageScaffold,
16
+ // only a body with a CustomScrollView.
17
+ child: CustomScrollView (
18
+ slivers: [
19
+ // Add the navigation bar to the CustomScrollView.
20
+ const CupertinoSliverNavigationBar (
21
+ // Provide a standard title.
22
+ largeTitle: Text (title),
23
+ ),
24
+ // #docregion SliverList
25
+ // Next, create a SliverList
26
+ SliverList (
27
+ // Use a delegate to build items as they're scrolled on screen.
28
+ delegate: SliverChildBuilderDelegate (
29
+ // The builder function returns a ListTile with a title that
30
+ // displays the index of the current item.
31
+ (context, index) =>
32
+ CupertinoListTile (title: Text ('Item #$index ' )),
33
+ // Builds 50 ListTiles
34
+ childCount: 50 ,
35
+ ),
36
+ ),
37
+ // #enddocregion SliverList
38
+ ],
39
+ ),
40
+ ),
41
+ );
42
+ }
43
+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ 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: [
@@ -21,6 +21,8 @@ class MyApp extends StatelessWidget {
21
21
// Provide a standard title.
22
22
title: Text (title),
23
23
// Allows the user to reveal the app bar if they begin scrolling
24
+ pinned: true ,
25
+ // Allows the user to reveal the app bar if they begin scrolling
24
26
// back up the list of items.
25
27
floating: true ,
26
28
// Display a placeholder widget to visualize the shrinking size.
@@ -36,8 +38,8 @@ class MyApp extends StatelessWidget {
36
38
// The builder function returns a ListTile with a title that
37
39
// displays the index of the current item.
38
40
(context, index) => ListTile (title: Text ('Item #$index ' )),
39
- // Builds 1000 ListTiles
40
- childCount: 1000 ,
41
+ // Builds 50 ListTiles
42
+ childCount: 50 ,
41
43
),
42
44
),
43
45
// #enddocregion SliverList
Original file line number Diff line number Diff line change
1
+ import 'package:flutter/cupertino.dart' ;
2
+
3
+ class MyApp extends StatelessWidget {
4
+ const MyApp ({super .key});
5
+
6
+ @override
7
+ Widget build (BuildContext context) {
8
+ // #docregion CustomScrollView
9
+ return const CupertinoApp (
10
+ home: CupertinoPageScaffold (
11
+ // No navigation bar property provided yet.
12
+ child: CustomScrollView (
13
+ // Add the navigation bar and list of items as slivers in the next steps.
14
+ slivers: < Widget > [],
15
+ ),
16
+ ),
17
+ );
18
+ // #enddocregion CustomScrollView
19
+ }
20
+ }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ class MyApp extends StatelessWidget {
7
7
Widget build (BuildContext context) {
8
8
// #docregion CustomScrollView
9
9
return const Scaffold (
10
- // No appBar property provided, only the body .
10
+ // No app bar property provided yet .
11
11
body: CustomScrollView (
12
12
// Add the app bar and list of items as slivers in the next steps.
13
13
slivers: < Widget > [],
Original file line number Diff line number Diff line change
1
+ import 'package:flutter/cupertino.dart' ;
2
+
3
+ void main () => runApp (const MyApp ());
4
+
5
+ class MyApp extends StatelessWidget {
6
+ const MyApp ({super .key});
7
+
8
+ @override
9
+ Widget build (BuildContext context) {
10
+ const title = 'Floating Navigation Bar' ;
11
+
12
+ return CupertinoApp (
13
+ title: title,
14
+ home: CupertinoPageScaffold (
15
+ // No navigation bar provided to CupertinoPageScaffold,
16
+ // only a body with a CustomScrollView.
17
+ // #docregion SliverAppBar
18
+ child: CustomScrollView (
19
+ slivers: [
20
+ // Add the navigation bar to the CustomScrollView.
21
+ const CupertinoSliverNavigationBar (
22
+ // Provide a standard title.
23
+ largeTitle: Text (title),
24
+ ),
25
+ ],
26
+ ),
27
+ // #enddocregion SliverAppBar
28
+ ),
29
+ );
30
+ }
31
+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ class MyApp extends StatelessWidget {
22
22
// Provide a standard title.
23
23
title: Text (title),
24
24
// Allows the user to reveal the app bar if they begin scrolling
25
+ pinned: true ,
26
+ // Allows the user to reveal the app bar if they begin scrolling
25
27
// back up the list of items.
26
28
floating: true ,
27
29
// Display a placeholder widget to visualize the shrinking size.
There was a problem loading the remainder of the diff.
You can’t perform that action at this time.
0 commit comments