[FIXED] Flutter AlertDialog Navigator.pop(context) returning a black screen


I am using NetworkGiffyDialog for my custom alert dialog, but sometimes the background is black screen and the app crashes
Problem here:

onOkButtonPressed: () { Navigator.of(context).pop();

Functions I call:

void showAlert(BuildContext context, String txt, String logo) {
          context: context,
          builder: (_) => NetworkGiffyDialog(
                Image: Image.asset("Assets/" + logo + ".gif"),
                title: Text('Product Radar',
                    textAlign: TextAlign.center,
                        TextStyle(fontSize: 22.0, fontWeight: FontWeight.w600)),
                Description: text(
                  textAlign: TextAlign.center,
                onOkButtonPressed: () {


The contextNavigator.of(context) – that I am using in this code – is what I pass to the showAlert function which is Probably the context of the root that is showing the dialog. So calling pop() actually pops the root, not the dialog. If it’s the first route in the navigation stack, the result will be the black screen you mentioned.

Replace builder: (_) with builder: (BuildContext context) to Navigator.of(context).pop();< /code > Since we are actually using the context of the dialog, the dialog will be closed.

Answered By - Ovidiu

Answer Checked By - Robin (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published