Skip to content

Instantly share code, notes, and snippets.

@androidfanatic
Created February 18, 2020 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save androidfanatic/73ff769f4cbaf16fca8cdd4b7bf585a4 to your computer and use it in GitHub Desktop.
Save androidfanatic/73ff769f4cbaf16fca8cdd4b7bf585a4 to your computer and use it in GitHub Desktop.
/// 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