android - 如何在 FlatButton 单击时关闭 AlertDialog?

标签 android ios flutter flutter-alertdialog

我有以下 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

最佳答案

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

关于android - 如何在 FlatButton 单击时关闭 AlertDialog?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44159819/

相关文章:

android - Android 6.0 中的 abortBroadcast()

flutter - 如何在 flutter 中设置库比蒂诺日期选择器的最大日期?

ios - 在 iphone X 中带有粘性页脚的 UICollectionView,内容滚动到页脚下方的区域

ios - Xcode 在验证过程中遇到了问题?

ios - 滚动 UITableView 时的值变化

java - Flutter 中的 Android 许可证

flutter - 如何在 ListView.builder flutter 中正确使用 findChildIndexCallback?

android - 在 Android 中使用录音的 SpeechRecognizer

Android:动态设置ImageView?

java - 使用 zxing 库的扫描仪 Activity 的自定义布局