How to handle the code after showDialog is dismissed in Flutter?

By using the then function we can handle the code after dialog dismiss

 isShow=false;
if( isShow==fasle){
showDialog(
  context: context,
  builder: (BuildContext context) {
    // return object of type Dialog
    return AlertDialog(
      title: new Text("Alert Dialog title"),
      content: new Text("Alert Dialog body"),
      actions: <Widget>[
        // usually buttons at the bottom of the dialog
        new FlatButton(
          child: new Text("Close"),
          onPressed: () {
            isShow = false;
            Navigator.of(context).pop();
          },
        ),
      ],
    );
  },
)
}

 

In the above code when "isShow" value is false then i am going to show the Dialog and while showing the dialog set  variable "isShow" to true

After dismiss the dialog again set the value to fasle, so that ican show the dialog alternatively, but when i press the back button this will not set the "isShow" to fasle, for the next iteration it will not show the Dialog.

To handle this scenario i have added then() function for the showDialog.

Let's updated code is 

isShow=false;
if( isShow==fasle){
showDialog(
  context: context,
  builder: (BuildContext context) {
    // return object of type Dialog
    return AlertDialog(
      title: new Text("Alert Dialog title"),
      content: new Text("Alert Dialog body"),
      actions: <Widget>[
        // usually buttons at the bottom of the dialog
        new FlatButton(
          child: new Text("Close"),
          onPressed: () {
            isShow = false;
            Navigator.of(context).pop();
          },
        ),
      ],
    );
  },
)

.then((value){

  isShow = false;
});

 

 

By this way we can hanlde back button event also.