我有一个 FutureBuilder,它在获取数据时显示一个 CircularProgressIndicator。目前,CircularProgressIndicator 显示在我屏幕的左上角,当它显示时,它后面的屏幕上没有其他内容。我想让指示器居中,并在获取数据时将其作为覆盖在我的其他小部件前面。
class PriceScreen extends StatefulWidget {
@override
PriceScreenState createState() => PriceScreenState();
}
class PriceScreenState extends State<PriceScreen> {
Future<Map> futureData;
Future<Map> getData() async {
...
}
@override
void initState() {
super.initState();
futureData = getData();
}
@override
Widget build(BuildContext context) {
//get object of the provided class dataProvider
return Scaffold(
appBar: AppBar(
title: Text('My app'),
),
body: FutureBuilder<Object>(
future: futureData,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator();
} else
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
.
.
.
.
.
);
}
}