Created
June 25, 2020 12:34
-
-
Save velotiotech/82020b4644a88223569905be53af0080 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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