如何在 FlatButton 单击时关闭 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

原文由 Gustash 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 312
2 个回答

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

原文由 Collin Jackson 发布,翻译遵循 CC BY-SA 3.0 许可协议

使用 获取 包。然后 Get.back() 关闭 Modal

原文由 Alexis mouss 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题