【发布时间】:2020-02-27 12:28:58
【问题描述】:
在颤振中,我有一个带有取消和确认按钮的 showDialog()。确认按钮将触发对 API 的调用。我需要的是在单击后在 showDialog 窗口中显示“正在加载...”,一旦 API 调用完成以显示成功或失败。我该如何管理?或者我应该关闭窗口,等待回复并弹出一个成功或错误的新对话窗口?感谢您提供任何帮助或更好的建议。这是我到目前为止所拥有的:
void _showAlert(String textLabel, String action, String linkId) {
showDialog(
context: context,
//barrierDismissible: false, // on external click
builder: (_) => new AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
title: new Text(
'Please confirm:',
style: TextStyle(color: Colors.deepOrange, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
content: new Text(
textLabel,
style: new TextStyle(fontSize: 20.0),
),
actions: <Widget>[
new FlatButton(
onPressed: () {
Navigator.pop(context);
},
child: new Text('CANCEL')),
new FlatButton(
onPressed: () {
_postAction(action, linkId).then((_) => setState(() {}));
Navigator.pop(context);
},
child: new Text('I CONFIRM')),
],
));
}
【问题讨论】:
-
谢谢,但它应该发生在对话窗口中
标签: flutter showdialog