一尘不染

如何关闭FlatButton单击时的AlertDialog?

flutter

我有以下几点AlertDialog

showDialog(
            context: context,
            child: new AlertDialog(
              title: const Text("Location disabled"),
              content: const Text(
                  """
Location is disabled on this device. Please enable it and try again.
                  """),
              actions: [
                new FlatButton(
                  child: const Text("Ok"),
                  onPressed: _dismissDialog,
                ),
              ],
            ),
        );

_dismissDialog()该如何解雇说AlertDialog


阅读 210

收藏
2020-08-13

共1个答案

一尘不染

Navigator.pop()应该可以。您还可以使用它来返回对话框的结果(如果对话框为用户提供了选择)

2020-08-13