Flutter Flatter AlertDialog Navigator.pop(上下文)返回黑屏

Flutter Flatter AlertDialog Navigator.pop(上下文)返回黑屏,flutter,Flutter,我将NetworkGiffyDialog用于自定义alertdialog,但它会提供黑屏背景,有时应用程序会崩溃 这里的问题是: onOkButtonPressed: () { Navigator.of(context).pop(); 我调用的函数: void showAlert(BuildContext context, String txt, String logo) { showDialog( context: context, bu

我将NetworkGiffyDialog用于自定义alertdialog,但它会提供黑屏背景,有时应用程序会崩溃 这里的问题是:

onOkButtonPressed: () { Navigator.of(context).pop(); 
我调用的函数:

void showAlert(BuildContext context, String txt, String logo) {
      showDialog(
          context: context,
          builder: (_) => NetworkGiffyDialog(
                image: Image.asset("Assets/" + logo + ".gif"),
                title: Text('Produit Radar',
                    textAlign: TextAlign.center,
                    style:
                        TextStyle(fontSize: 22.0, fontWeight: FontWeight.w600)),
                description: Text(
                  txt,
                  textAlign: TextAlign.center,
                ),
                onOkButtonPressed: () {
                  Navigator.of(context).pop();
                },
              ));
    }

与此代码一起使用的
context
导航器(context)-是传递给
showarert
函数的导航器,它可能是显示对话框的路径的上下文。因此,当您调用
pop()
时,实际上是在弹出路由,而不是对话框。如果这是导航堆栈中的第一条路线,结果将是您提到的黑屏


builder:(41;
替换为
builder:(BuildContext)
以便在调用
Navigator.of(context).pop()时您实际使用的是对话框的上下文,因此对话框将被取消。

我调用多次that fct的问题,如果用户单击“确定”,则无问题对话框将关闭,但当未执行任何操作且在该对话框中diplau=ying rslt后(显示示例3对话框),用户需要多次按“确定”关闭所有对话框