A simple material design dialog.

A simple dialog offers the user a choice between several options. A simple dialog has an optional title that is displayed above the choices.

For dialogs that inform the user about a situation, consider using an AlertDialog.

Typically passed as the child widget to showDialog, which displays the dialog.

Sample code

In this example, the user is asked to select between two options. These options are represented as an enum. The showDialog method here returns a Future that completes to a value of that enum. If the user cancels the dialog (e.g. by hitting the back button on Android, or tapping on the mask behind the dialog) then the future completes with the null value.

The return value in this example is used as the index for a switch statement. One advantage of using an enum as the return value and then using that to drive a switch statement is that the analyzer will flag any switch statement that doesn't mention every value in the enum.

Future<Null> _askedToLead() async {
  switch (await showDialog<Department>(
    context: context,
    child: new SimpleDialog(
      title: const Text('Select assignment'),
      children: <Widget>[
        new SimpleDialogOption(
          onPressed: () { Navigator.pop(context, Department.treasury); },
          child: const Text('Treasury department'),
        new SimpleDialogOption(
          onPressed: () { Navigator.pop(context, Department.state); },
          child: const Text('State department'),
  )) {
    case Department.treasury:
      // Let's go.
      // ...
    case Department.state:
      // ...

See also:



SimpleDialog({Key key, Widget title, EdgeInsetsGeometry titlePadding, List<Widget> children, EdgeInsetsGeometry contentPadding })
Creates a simple dialog. [...]


children List<Widget>
The (optional) content of the dialog is displayed in a SingleChildScrollView underneath the title. [...]
contentPadding EdgeInsetsGeometry
Padding around the content. [...]
title Widget
The (optional) title of the dialog is displayed in a large font at the top of the dialog. [...]
titlePadding EdgeInsetsGeometry
Padding around the title. [...]
hashCode int
The hash code for this object. [...]
read-only, inherited
key Key
Controls how one widget replaces another widget in the tree. [...]
final, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


build(BuildContext context) Widget
Describes the part of the user interface represented by this widget. [...]
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree. [...]
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder description) → void
Add additional properties associated with the node. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toDiagnosticsNode({String name, DiagnosticsTreeStyle style }) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by toStringDeep. [...]
toString({DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a string representation of this object.
toStringDeep({String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a string representation of this node and its descendants. [...]
toStringShallow({String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug }) String
Returns a one-line detailed description of the object. [...]
toStringShort() String
A short, textual description of this widget.


operator ==(other) bool
The equality operator. [...]