我想仅在我未来加载数据(ConnectionState.done)之后才显示一个浮动操作按钮。
它只是在等待期间显示,并不酷。我希望它在未来处理后显示(ConnectionState.done)。
有人给小费吗?
我的代码:
@override
void initState() {
_future = getFuture();
super.initState();
}
Future<List<Associated>> getFuture() async {
return _webClient.findAll();
}
//@override
Widget build(BuildContext context) {
return Scaffold(
body: FutureBuilder<List<Associated>>(
future: _future,
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
break;
case ConnectionState.waiting:
return Progress();
break;
case ConnectionState.active:
break;
case ConnectionState.done:
if (snapshot.hasData) {
final List<Associated> associateds = snapshot.data;
if (associateds.isNotEmpty) {
return Container(
child: Form(
child: SingleChildScrollView(
child: associatedWidgets(associateds),
),
),
);
}
}
return CenteredMessage(
'Not found.',
icon: Icons.warning,
);
break;
}
},
),
floatingActionButton: Button(
Icons.save,
onClick: () {
_update(context);
},
),
);
}