首页 > 解决方案 > 在 DART 中调用操作后如何更新我的页面?

问题描述

我需要在调用操作后更新我的页面,但直到现在我才能做到这一点。

这是我需要的一个例子:

onTap(){
// my logic
}

SOMEHOW UPDATE THE PAGE (RELOAD)


if (p.situacao == "R" && tA == "P") {
              Alert(
                context: context,
                type: AlertType.warning,
                title: "${p.num}?",
                buttons: [
                  DialogButton(
                    child: Text(
                      "Sim",
                      style: TextStyle(color: Colors.white, fontSize: 20),
                    ),
                    onPressed: () async {
                      APt.aPt();
                      await Future.delayed(Duration(seconds: 3));
                      await Confirmacao(context);
                    },
                    color: Color(0xFF0578be),
                  ),
                  DialogButton(
                    child: Text(
                      "Não",
                      style: TextStyle(color: Colors.white, fontSize: 20),
                    ),
                    onPressed: () => Navigator.pop(context),
                    color: Color(0xFF0578be),
                  )
                ],
              ).show();
            }

我需要重新加载内容。

标签: flutterdartactionreload

解决方案


You can Update UI using just call setState(() {}) 

 onTap(){

    setState(() {});

    }

但是,如果您想重新加载 api 调用,那就另当别论了。


推荐阅读