循环进度不断旋转

时间:2019-09-11 13:15:17

标签: 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(), }
         ), 
     );

1 个答案:

答案 0 :(得分:3)

  setState(() {
        posts = res;
        isLoading = false;
      });

改为使用FutureBuilder