Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 25, 2020 12:34
Embed
What would you like to do?
/// display a dialog that accepts text
_promptDialog(BuildContext context) {
String _todoLabel = '';
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('Enter TODO item'),
content: TextField(
onChanged: (value) => _todoLabel = value,
decoration: InputDecoration(hintText: 'Add new TODO item')),
actions: <Widget>[
FlatButton(
child: new Text('CANCEL'),
onPressed: () => Navigator.of(context).pop(),
),
FlatButton(
child: new Text('ADD'),
onPressed: () {
setState(() => todos.add(Todo(_todoLabel, false)));
/// dismisses the alert dialog
Navigator.of(context).pop();
},
)
],
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment