【发布时间】:2021-03-11 19:46:54
【问题描述】:
我需要在调用操作后更新我的页面,但直到现在我才能够这样做。
这是我需要的一个例子:
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();
}
我需要重新加载内容。
【问题讨论】:
-
状态管理工具的完美工作,例如 Provider 或 RiverPod 或 Cubit...选择您喜欢的。然后,您可以让页面依赖于数据的更新。
-
@RandalSchwartz 不是用锤子杀死蚂蚁吗?如果目标只是刷新页面,他可以在有状态小部件中使用简单的 setState 调用
-
不清楚逻辑是否在同一个小部件中。
标签: flutter dart action reload