Unverified Commit 7fdd9218 authored by Pedro Massango's avatar Pedro Massango Committed by GitHub

Proposal: deprecate autovalidate parameter of the Form, FormField and TextFormField widget (#61648)

parent 4fde217d
......@@ -95,7 +95,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
));
}
bool _autovalidate = false;
AutovalidateMode _autovalidateMode = AutovalidateMode.disabled;
bool _formWasEdited = false;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
......@@ -104,7 +104,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
void _handleSubmitted() {
final FormState form = _formKey.currentState;
if (!form.validate()) {
_autovalidate = true; // Start validating on every change.
_autovalidateMode = AutovalidateMode.always; // Start validating on every change.
showInSnackBar('Please fix the errors in red before submitting.');
} else {
form.save();
......@@ -180,7 +180,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
bottom: false,
child: Form(
key: _formKey,
autovalidate: _autovalidate,
autovalidateMode: _autovalidateMode,
onWillPop: _warnUserAboutInvalidData,
child: Scrollbar(
child: SingleChildScrollView(
......
......@@ -1468,6 +1468,11 @@ class DropdownButtonFormField<T> extends FormField<T> {
InputDecoration decoration,
FormFieldSetter<T> onSaved,
FormFieldValidator<T> validator,
@Deprecated(
'Use autoValidateMode parameter which provide more specific '
'behaviour related to auto validation. '
'This feature was deprecated after v1.19.0.'
)
bool autovalidate = false,
AutovalidateMode autovalidateMode,
}) : assert(items == null || items.isEmpty || value == null ||
......
......@@ -88,7 +88,7 @@ export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType;
/// },
/// child: FocusTraversalGroup(
/// child: Form(
/// autovalidate: true,
/// autovalidateMode: AutovalidateMode.always,
/// onChanged: () {
/// Form.of(primaryFocus.context).save();
/// },
......@@ -158,6 +158,11 @@ class TextFormField extends FormField<String> {
SmartDashesType smartDashesType,
SmartQuotesType smartQuotesType,
bool enableSuggestions = true,
@Deprecated(
'Use autoValidateMode parameter which provide more specific '
'behaviour related to auto validation. '
'This feature was deprecated after v1.19.0.'
)
bool autovalidate = false,
bool maxLengthEnforced = true,
int maxLines = 1,
......
......@@ -78,7 +78,12 @@ class Form extends StatefulWidget {
const Form({
Key key,
@required this.child,
this.autovalidate = false,
@Deprecated(
'Use autoValidateMode parameter which provide more specific '
'behaviour related to auto validation. '
'This feature was deprecated after v1.19.0.'
)
bool autovalidate = false,
this.onWillPop,
this.onChanged,
AutovalidateMode autovalidateMode,
......@@ -114,11 +119,6 @@ class Form extends StatefulWidget {
/// {@macro flutter.widgets.child}
final Widget child;
/// If true, form fields will validate and update their error text
/// immediately after every change. Otherwise, you must call
/// [FormState.validate] to validate.
final bool autovalidate;
/// Enables the form to veto attempts by the user to dismiss the [ModalRoute]
/// that contains the form.
///
......@@ -319,7 +319,12 @@ class FormField<T> extends StatefulWidget {
this.onSaved,
this.validator,
this.initialValue,
this.autovalidate = false,
@Deprecated(
'Use autoValidateMode parameter which provide more specific '
'behaviour related to auto validation. '
'This feature was deprecated after v1.19.0.'
)
bool autovalidate = false,
this.enabled = true,
AutovalidateMode autovalidateMode,
}) : assert(builder != null),
......@@ -360,12 +365,6 @@ class FormField<T> extends StatefulWidget {
/// An optional value to initialize the form field to, or null otherwise.
final T initialValue;
/// If true, this form field will validate and update its error text
/// immediately after every change. Otherwise, you must call
/// [FormFieldState.validate] to validate. If part of a [Form] that
/// auto-validates, this value will be ignored.
final bool autovalidate;
/// Whether the form is able to receive user input.
///
/// Defaults to true. If [autovalidateMode] is not [AutovalidateMode.disabled],
......@@ -382,8 +381,8 @@ class FormField<T> extends StatefulWidget {
/// will auto validate even without user interaction and
/// if [AutovalidateMode.disabled] the auto validation will be disabled.
///
/// Defaults to [AutovalidateMode.disabled] if [autovalidate] is false which
/// means no auto validation will occur. If [autovalidate] is true then this
/// Defaults to [AutovalidateMode.disabled] if `autovalidate` is false which
/// means no auto validation will occur. If `autovalidate` is true then this
/// is set to [AutovalidateMode.always] for backward compatibility.
/// {@endtemplate}
final AutovalidateMode autovalidateMode;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment