android - Flutter AlertDialog Navigator 弹出黑屏问题

标签 android mobile dart flutter flutter-layout

我有一个奇怪的问题,AlertDialog 在 flutter 中关闭对话框。我正在使用下面的代码 fragment 来关闭 flutter 文档中提到的对话框。

 Navigator.of(dialogContext).pop();

但是显示它如何不起作用并使应用程序进入非 Activity 模式并变成黑屏窗口。为了让它再次工作,我必须终止应用程序并重新启动。

这是flutter中alertdialog的完整代码
Future<Null> _showDialogContactDial(context, Contact contactRecord) async {

  return showDialog<Null>(
    context: context,
    barrierDismissible: true, // user must tap button!
    builder: (BuildContext dialogContext) {
      return new AlertDialog(
        title: new Text('Confirm Number'),
        content: new SingleChildScrollView(
          child: new ListBody(
            children: <Widget>[
              new TextFormField(
                maxLines: 1,
                decoration: new InputDecoration(hintText: 'Number'),
                keyboardType: TextInputType.number,
                autofocus: false,
                initialValue: contactRecord.phoneNumber.number,
              ),
            ],
          ),
        ),
        actions: <Widget>[
          new FlatButton(
            child: new Text(
              'Call',
              style: TextStyle(color: Colors.black),
            ),
            onPressed: () {
              Navigator.of(dialogContext).pop();


              _launchURL(
                  context);
            },
          ),
          new FlatButton(
            color: Colors.red,
            child: new Text('Close', style: TextStyle(color: Colors.white)),
            onPressed: () {
              Navigator.of(dialogContext).pop();
            },
          ),
        ],
      );
    },
  );
}

我还注意到它适用于一个按钮“调用”而没有任何问题,但不适用于取消警报对话框,正如您在两个按钮操作的相同代码 fragment 中看到的那样。

dialog
after the dialogdismiss
app
帮助将不胜感激。

最佳答案

只需添加 rootNavigator:true

Navigator.of(dialogcon, rootNavigator: true).pop();

关于android - Flutter AlertDialog Navigator 弹出黑屏问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53674433/

相关文章:

Android Facebook SDK 不显示登录屏幕

flutter - 列表包含 'Future<dynamic>' 的实例

flutter - 在 flutter 中,在 initstate() 之前调用了dependOnInheritedElement()

flutter - 如何为 `extending a class` 编写有意义的测试?

android - 试图制作单进程设备......这可能吗??? :(

android - 如何在不缩放背景的情况下增加 Android 按钮的点击区域?

android - Firebase 分析 : "select_content" events with "Content_type" value: (not set)

java - OnBootReceiver 可以工作,但找不到 AlarmReceiver

Android 在使用固定宽度视口(viewport)元标记时忽略最大比例

ios - 如何在 iOS React Native App 中将方向锁定为纵向?