title: Run a function AFTER that the alertbox has been dismissed
body: <p>I already read countless links like <a href="https://stackoverflow.com/questions/49706046/how-run-code-after-showdialog-is-dismissed-in-flutter">this one</a> but it does not help.</p>
  
  <p>The use case is very simple, I want to run a function AFTER the alert box has been dismissed.</p>
  
  <pre class="lang-dart prettyprint-override"><code>void dummyFunc()  {
  
              sleep(Duration(seconds:3));
              print("done");
  
  }
  
  Future&lt;bool&gt; displayDialog() async {
              return showDialog&lt;bool&gt;(
  
                  context: context,
                  barrierDismissible: false, // user must tap button!
                  builder: (BuildContext context) {
                      return AlertDialog(
  
                          title: Text('AlertDialog Title'),
                          content: SingleChildScrollView(
                              child: ListBody(
                                  children: &lt;Widget&gt;[
                                      Text('This is a demo alert dialog.'),
                                      Text('Would you like to approve of this message?'),
                                  ],
                              ),
                          ),
                          actions: &lt;Widget&gt;[
                              FlatButton(
                                  child: Text('Decline'),
                                  onPressed: () {
                                      Navigator.of(context).pop(false);
                                  },
                              ),
                              FlatButton(
                                  child: Text('Approve'),
                                  onPressed: () {
                                      Navigator.of(context).pop(true);
                                  },
                              ),
                          ],
                          elevation: 24.0,
                          shape:RoundedRectangleBorder(),
                      );
                  },
              );
          }
  
  var button = AnimatedOpacity(
              opacity: 1.0,
              duration: Duration(milliseconds: 500),
              child: FloatingActionButton(
                  tooltip: 'Start',
                  child: Icon(iconShape),
                  onPressed: () async {
                      bool shouldUpdate = await displayDialog();
                      print(shouldUpdate);
                      if (shouldUpdate)
                            dummyFunc();
  
                  })
          );
  </code></pre>
  
  <p>But the alert dialog is dismissed 3sd after.</p>
  
  <p>Kindly let me know what I am doing wrong, Thank you~</p>