简体   繁体   English

Flutter 对话框未完全关闭

[英]Flutter dialog not closing completely

We have a Flutter dialog that when we click Ok and it sends the user home... the dialog lingers on the screen even after sending them home and then goes away which is annoying.我们有一个 Flutter 对话框,当我们单击“确定”时,它会将用户送回家……即使在将用户送回家后,该对话框仍停留在屏幕上,然后消失,这很烦人。

Here is the code for the dialog:这是对话框的代码:

 Future<void> _requestSupportDialog(BuildContext context, User user, Features features) {
    return showDialog<void>(
    context: context,
    builder: (BuildContext context) {
    return AlertDialog(
    title: Text('Success! You have been entered into the support queue'),
    content: const Text('Support it on its way'),
    actions: <Widget>[
      FlatButton(
        child: Text('Ok'),
        onPressed: () {
          // Send them HOME.
          Navigator.of(context).push(new MaterialPageRoute(builder: (BuildContext context) => new FlutterReduxApp(user: user, features: features)));
         },
        ),
      ],
    );
  },
);
}
Navigator.of(context, rootNavigator: true).pop();
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (BuildContext context)=>Home(son: 0,)));

在推送到新路线之前,尝试先弹出以关闭对话框。

Navigator.of(context).pop()

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

Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (BuildContext context)=>Home(son: 0,))); Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (BuildContext context)=>Home(son: 0,)));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM