📅  最后修改于: 2022-03-11 15:00:49.379000             🧑  作者: Mango
// build fixed items outside of the FutureBuilder for efficiency
final someOtherSliver = SliverToBoxAdapter(...);
return FutureBuilder>(
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: [
someOtherSliver,
newsListSliver
],
);
},
);