Distinguish canceling a route pop from bubbling the pop up to the next level (#9165)

This commit is contained in:
Jason Simmons
2017-04-04 16:42:31 -07:00
committed by GitHub
parent 5cbd1a33a5
commit 3000c8bb59
4 changed files with 47 additions and 12 deletions

View File

@@ -75,12 +75,12 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
return null;
}
Future<bool> _warnUserAboutInvalidData() {
Future<bool> _warnUserAboutInvalidData() async {
final FormState form = _formKey.currentState;
if (!_formWasEdited || form.validate())
return new Future<bool>.value(true);
if (form == null || !_formWasEdited || form.validate())
return true;
return showDialog<bool>(
return await showDialog<bool>(
context: context,
child: new AlertDialog(
title: new Text('This form has errors'),
@@ -96,7 +96,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
),
],
),
);
) ?? false;
}
@override