How to dismiss an AlertDialog on a FlatButton click?

前端 未结 16 1315
轮回少年
轮回少年 2021-02-03 16:44

I have the following AlertDialog.

showDialog(
            context: context,
            child: new AlertDialog(
              title: const Text(\"Lo         


        
16条回答
  •  不思量自难忘°
    2021-02-03 17:07

    Generally Navigator.pop(context); works.

    But If the application has multiple Navigator objects and dialogBox doesn't close, then try this

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

    If you want to pass result call, try

    Navigator.pop(context,result);
    

    OR

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

提交回复
热议问题