Marwan
Marwan

Reputation: 47

How to hide show AlertDialog flutter

I am using showAlertDialog to alert the user to sign in with the following code:


  showAlertDialog(BuildContext context){
    AlertDialog alert=AlertDialog(
      content: new Row(
        children: [
          CircularProgressIndicator(),
          Container(margin: EdgeInsets.only(left: 5),child:Text("Loading" )),
        ],),
    );
    showDialog(barrierDismissible: false,
      context:context,
      builder:(BuildContext context){
        return alert;
      },
    );
  }



And through the next line of code I run and show it to the user:

showAlertDialog(context);

The problem now: I am trying to stop or hide its work through the following line of code, but the matter does not work, I cannot hide it.

 Navigator.pop(context);

Is there a solution for that? I need to stop it and hide it.

thank you

Upvotes: 0

Views: 285

Answers (1)

harsha.kuruwita
harsha.kuruwita

Reputation: 1331

You can use

Navigator.of(context).pop();

Upvotes: 1

Related Questions