Exemple #1
0
        private Future <bool> _warnUserAboutInvalidData()
        {
            FormState form = _formKey.currentState;

            if (form == null || !_formWasEdited || form.validate())
            {
                return(Future.value(true).to <bool>());
            }

            return(material_.showDialog <bool>(
                       context: context,
                       builder: (BuildContext context) =>
            {
                return new AlertDialog(
                    title: new Text("This form has errors"),
                    content: new Text("Really leave this form?"),
                    actions: new List <Widget>
                {
                    new FlatButton(
                        child: new Text("YES"),
                        onPressed: () => { Navigator.of(context).pop(true); }
                        ),
                    new FlatButton(
                        child: new Text("NO"),
                        onPressed: () => { Navigator.of(context).pop(false); }
                        )
                }
                    );
            }
                       ) ?? Future.value(false).to <bool>());
        }
Exemple #2
0
        private void _handleSubmitted()
        {
            FormState form = _formKey.currentState;

            if (!form.validate())
            {
                _autovalidate = true; // Start validating on every change"
                showInSnackBar("Please fix the errors in red before submitting.");
            }
            else
            {
                form.save();
                showInSnackBar($"{person.name}'s phone number is ${person.phoneNumber}");
            }
        }
        void _handleOk()
        {
            if (_entryMode == DatePickerEntryMode.input)
            {
                FormState form = _formKey.currentState;
                if (!form.validate())
                {
                    setState(() => _autoValidate = true);
                    return;
                }

                form.save();
            }

            Navigator.pop(context, _selectedDate);
        }