【发布时间】:2020-08-23 03:48:57
【问题描述】:
我是 Flutter 的新手,但遇到了问题。
我正在使用 mobx。在我看来,我有一个按钮,并且在此按钮内部,
我正在等待 showDialog 属性更改以显示对话框视图。但是,在 onpress 中,显示对话框不起作用。有没有其他方法可以做到这一点?
我的控制器
@observable
bool showDialog = false;
@action
Future callLoginService() async {
await Future.delayed(Duration(seconds: 6));
showDialog = true;
}
查看
Observer(
builder: (_) {
return Center(
child: RaisedButton(
child: Text("TESTE"),
onPressed: () async {
controller.callLoginService();
if (controller.showDialog) {
final action = await InfoDialogView.showAlertDialog(
context, "Try again", 'Invalid user');
if (action == DialogAction.abort) {
controller.showDialog = false;
}
}
},
),
);
},
),
【问题讨论】: