flutter - 在 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();
}
我需要重新加载内容。
解决方案
You can Update UI using just call setState(() {})
onTap(){
setState(() {});
}
但是,如果您想重新加载 api 调用,那就另当别论了。
推荐阅读
- python - 如何打印“\”并避免代码拆分?
- sql - 与字段的时差
- html - 如何使 fullcalendar4 中的可拖动事件区域可滚动?
- c - 从函数返回结构给我分段错误
- javascript - 我无法从我的 Google Play 商店控制台获取订阅 ID,导致找不到错误项目
- html - 看起来我的媒体查询没有改变我的字体大小
- java - 从 IntelliJ 运行时添加排除的 gradle 依赖项
- javascript - 如何将数字分解为它们的数字值?
- javascript - ReactJs:单击提交按钮时读取所有表单输入值
- javascript - then() 中的 for 循环不迭代