flutter use future builder in custom scroll view code example
Example: custom scrollview inside futurebuilder
// build fixed items outside of the FutureBuilder for efficiency
final someOtherSliver = SliverToBoxAdapter(...);
return FutureBuilder<List<Data>>(
future: getQuake(), // this is a code smell. Make sure that the future is NOT recreated when build is called. Create the future in initState instead.
builder: (context, snapshot){
Widget newsListSliver;
if(snapshot.hasData) {
newsListSliver = SliverList(delegate: SliverChildBuilderDelegate(...))
} else {
newsListSliver = SliverToBoxAdapter(child: CircularProgressIndicator(),);
}
return CustomScrollView(
slivers: <Widget>[
someOtherSliver,
newsListSliver
],
);
},
);