Skip to content

Instantly share code, notes, and snippets.

@NilsBacke
Created June 24, 2018 23:50
Show Gist options
  • Save NilsBacke/160c5fce13d36f7ee244cb5dcd5520c1 to your computer and use it in GitHub Desktop.
Save NilsBacke/160c5fce13d36f7ee244cb5dcd5520c1 to your computer and use it in GitHub Desktop.
An example of an alert dialog in flutter.
// user defined function
void _showDialog() {
// flutter defined function
showDialog(
context: context,
builder: (BuildContext context) {
// return object of type Dialog
return AlertDialog(
title: new Text("Alert Dialog title"),
content: new Text("Alert Dialog body"),
actions: <Widget>[
// usually buttons at the bottom of the dialog
new FlatButton(
child: new Text("Close"),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment