Flutter showDialog,带有加载微调器和确认

问题描述 投票:0回答:1

在扑朔迷离中,我有一个带取消和确认按钮的showDialog()。确认按钮将触发对API的调用。我需要的是在单击后以及API调用完成以显示成功或失败之后,在showDialog窗口中显示“正在加载...”。我该如何处理?还是我应该关闭窗口,等待答复并弹出一个新对话框,成功或错误?感谢您的帮助或更好的建议。这是我到目前为止所拥有的:

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
1个回答
0
投票

您可以尝试一下,这只是个主意。

© www.soinside.com 2019 - 2024. All rights reserved.