Flutter showDialog()

Want to present some information, an alert, some detail, a warrant, an offer? showDialog is your friend, description:

showDialog(BuildContext context, ((BuildContext) → Widget) builder);

it takes two arguments:

  • context: the context to show the dialog.
  • builder: the method to build the content, taking a BuildContext as input and a Widgetas return value.

Actual example:

// Upon a user action, calls
void userDidSomething(){
   showDialog(context: context, builder: box);

// A Button, tap and dismiss action
Widget box(BuildContext context) {
    return RaisedButton(
          child: Text("Alert - Tap to dismiss"),
          color: Colors.yellow
          onPressed: () {

What’s next?

  • Try AlertDialog for proper dialog box
  • Try nesting the RaisedButton in some other layout elements

Happy Coding 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s