flutter - 循环进度不断旋转
问题描述
我试图实现 CircularProgressBar 以实现颤振,但不知何故,它一直在旋转,加载数据后不会关闭。
从 NetworkFile 调用数据
final getCategory = NetworkFile().getCategories(elem);
bool isLoading = true;
List posts = [];
void getPostsList() async {
var res = await getCategory;
if (this.mounted) {
setState(() {
posts = res;
});
}
}
退回容器
return isLoading ? CircularProgressIndicator() : Container(
child: ListView.builder(
itemCount: posts == null ? 0 : posts.length,
itemBuilder: (BuildContext context, int index) {
return Column(), }
),
);
解决方案
setState(() {
posts = res;
isLoading = false;
});
改为使用FutureBuilder
。
推荐阅读
- debugging - NuGet/MyGet 调试抛出未找到源代码错误
- sql - 每组记录只显示一次值
- git - 从现有的 Git 存储库中进行稀疏签出?
- jquery - 选择所有在 webgrid Jquery 和 ASP.net MVC 中不起作用的复选框
- jenkins - 无法启动 Windows 从代理 (Jenkins)
- python - aiohhttp 中的会话重用
- java - 使用杰克逊读取 yaml 到对象
- javascript - 使用 jquery ajax 调用 nodejs 获取 json 数据
- azure - 如何找到blob的路径?
- ios - 你能给我上传 iOS 应用程序错误 ITMS-90035 的解决方案吗?