Skip to content

Instantly share code, notes, and snippets.

Created June 25, 2020 12:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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>[
child: new Text('CANCEL'),
onPressed: () => Navigator.of(context).pop(),
child: new Text('ADD'),
onPressed: () {
setState(() => todos.add(Todo(_todoLabel, false)));
/// dismisses the alert dialog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment