颤振对话框未完全关闭

时间:2020-02-06 18:45:21

标签: flutter dart

我们有一个Flutter对话框,当我们单击OK并将其发送给用户时,该对话框仍然停留在屏幕上,即使将他们发送回家后又消失了,这很烦人。

以下是对话框的代码:

 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)));
         },
        ),
      ],
    );
  },
);
}

3 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

在尝试使用新路线之前,请先弹出以关闭对话框。

Navigator.of(context).pop()

答案 2 :(得分:0)

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

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