Flutter:进度对话框没有隐藏

标签 flutter dart

我正在使用 progress_dialog 1.2.0 包在我的应用程序中显示进度对话框,它在我调用 pr.show() 时显示,但在我调用 pr.hide() 时没有隐藏。

onTap: () async {
                                      pr.show();

                                      print('clicked custom category');
                                      print(categorylist[index].catName);
                                      print(categorylist[index].catId);

//                                      await getAllProductsInCategory(categorylist[index].catId);


                                      setState(() {
                                        catId = categorylist[index].catId;
                                        myinitlist.clear();
                                        myinitlist = List.from(productList);
                                      pr.hide();
                                      });

                                   },

当我取消注释“getAllProductsInCategory()”函数时,它会隐藏对话框。
谁能帮我这个。
先感谢您。

最佳答案

尝试:

onTap: () async {
    pr.show();

    print('clicked custom category');
    print(categorylist[index].catName);
    print(categorylist[index].catId);

    setState(() {
      catId = categorylist[index].catId;
      myinitlist.clear();
      myinitlist = List.from(productList);

       Future.delayed(Duration(seconds: 3)).then((value) {
         pr.hide().whenComplete(() {
          print(pr.isShowing());
        });
       });
    });
 },

或者 :
onTap: () async {
    pr.show();

    print('clicked custom category');
    print(categorylist[index].catName);
    print(categorylist[index].catId);

   Future.delayed(Duration(seconds: 3)).then((value) {
    setState(() {
      catId = categorylist[index].catId;
      myinitlist.clear();
      myinitlist = List.from(productList);


         pr.hide().whenComplete(() {
          print(pr.isShowing());
        });
       });
    });
 },

关于Flutter:进度对话框没有隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58494494/

相关文章:

android - 如何以编程方式将文本元素添加到我的小部件/类?

flutter - 如何在参数更改时刷新当前路由?

image - Flutter:将图像文件从 url 复制到 firebase

flutter - 在 Flutter 中使用类以列表形式传递参数

Dart pub global run 无法解析脚本名称

flutter - 如何解决 Flutter 中的不可空错误?

git - Flutter:gitignore 被...忽略

flutter - 如何在 Flutter 中创建自定义日历?

dart - Flutter URL 启动器 Google map

flutter - 浏览 dart 中的嵌套字典