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 aWidget
as 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: () {
Navigator.of(context).pop();
},
);
}
What’s next?
- Try
AlertDialog
for proper dialog box - Try nesting the
RaisedButton
in some other layout elements
Happy Coding 🙂