【发布时间】:2021-04-15 21:01:46
【问题描述】:
总的来说,我是 Flutter 和 Dart 的新手,我正在尝试在页面加载期间进行扩展计算,但是当我尝试执行以下操作时加载器卡住了:
body: Center(
child:FutureBuilder(
future: _lorem()
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done){
print("loader");
return Center(
child: CircularProgressIndicator(
backgroundColor: Theme.of(context).primaryColor)
);
}
[...]
Future<void> _lorem() async {
//there is not a request to service, there is a more than one filter on map and some lists. I set the for loop for example of a local computation
return Future(() {
for (int i = 0; i < 50000; i++){
print(i);
}
}
);
}
【问题讨论】:
-
你能告诉我你为什么在 Future 中使用循环吗?
-
你能给我们你的 Future Builder 小部件的全部内容吗?
-
@AmonChowdhury 该视图是带有一些图表的摘要,我想在 Future 中插入计算以在其中显示加载器,但如果有不同的方法来获得该结果,我会整合
标签: android flutter dart asynchronous mobile