我需要在页面渲染之前从三个不同的 url 获取数据。所以,这是我的 ScopedModel 中的方法,包括多个 http.post 方法:
Future fetchData() async {
_isLoading = true;
notifyListeners();
await fetchAvailable();
await fetchOnProgress();
await fetchCompleted();
_isLoading = false;
notifyListeners();
}
fetchData 区域内的方法只是具有原始 Future 类型的经典 http.post 请求。
这是我的 FutureBuilder:
FutureBuilder(
future: model.fetchData(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
return snapshot.connectionState != ConnectionState.done
? Center(
child: CircularProgressIndicator(),
)
: Column.......
问题是,“未来”的功能,它不断执行,永无止境。我关于从服务器获取 json 的算法将正文中的变量膨胀到 ListView.builder 后代中。
输出正如我所说的递归发布请求。此外,我正在获取此日志,行数增量如 1 - 2 - 3 或 2 - 4 - 6 -8 等。
uid=10085(my.package.directory) 1.ui identical 1 lines
.......Other logs here
uid=10085(my.package.directory) 1.ui identical 3 lines
就这样继续下去……
此外,还有其他有用的方法可以在页面渲染之前处理少量数据吗?