How to dismiss an AlertDialog on a FlatButton click?

Navigator.pop() should do the trick. You can also use that to return the result of the dialog (if it presented the user with choices)


Navigator.of(context, rootNavigator: true).pop('dialog')

worked with me.


Navigator.pop(_)

worked for me, but the Flutter Team's gallery contains an example using:

Navigator.of(context, rootNavigator: true).pop()

which also works, and I am tempted to follow their lead.