Using StreamBuilder when creating an app with floating appbar. Use the below example code to create an app with floating appbar.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | return new Scaffold( body: new CustomScrollView(slivers: <Widget>[ new SliverAppBar( title: new Text('Sliver App Bar'), floating: true, snap: true, bottom: PreferredSize( preferredSize: const Size.fromHeight(90.0), child: new Text('dddd'), ), ), FutureBuilder<List<String>>( future: getPosts(), builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { return SliverList( delegate: new SliverChildBuilderDelegate((BuildContext context, int index) { return new Text(snapshot.data[index].toString()); }, childCount: snapshot.data.length), ); } else { return new SliverList( delegate: SliverChildListDelegate(buildTextViews(50)) ); } } ), ]), ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.