Flutter Widget 101 Part 6 (Alert and Simple Dialog)


https://medium.com/@nils.backe/flutter-alert-dialogs-9b0bb9b01d28

https://stackoverflow.com/questions/50964365/alert-dialog-with-rounded-corners-in-flutter

Dialogs

In essence, dialogs are pop-up for further user verification/notification.

There are few types of dialogs:
  1. AlertDialog (rows of buttons below body).
  2. SimpleDialog (handles scrolling of contents and no buttons below body).
  3. showCupertinoDialog (iOS-style).
  4. showGeneralDialog (allows customisations).

showDialog ()

3 Parameters. child is deprecated.  Return child from builder, example below.
BuildContext context,
Widget child,//deprecated WidgetBuilder builder,

showDialog(
    context:context,
    barrierDismissible: true,
    builder: (BuildContext context)
      {
      return AlertDialog(
        content: new Text("Welcome"),
        actions: <Widget>[
          new IconButton(
              icon: new Icon(Icons.launch),
              onPressed: (){Navigator.pop(context);}
          ),
        ],
      );
      });

AlertDialog

Limitation:
Limited content (vertical) else Title and Action would overflow.

Snackbar inside AlertDialog
http://cogitas.net/show-snackbar-flutter/
https://stackoverflow.com/questions/52223152/how-to-show-a-snackbar-from-async-executions-when-no-context-is-available/
https://blog.csdn.net/mp624183768/article/details/86289860

SimpleDialog

Common Issues: Updating with setState

More Examples

Comments

Popular posts from this blog

Setting up Terminal in Android Studio for Flutter and Bash Profile (For Mac)

Flutter Widget 101 Part 1 (Basic of Flutters, Layouts, Rows and Columns)

Flutter Widget 101 Part 4 (Navigation and Drawers)