Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7fdd9218
Unverified
Commit
7fdd9218
authored
Sep 02, 2020
by
Pedro Massango
Committed by
GitHub
Sep 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proposal: deprecate autovalidate parameter of the Form, FormField and TextFormField widget (#61648)
parent
4fde217d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
19 deletions
+28
-19
text_form_field_demo.dart
...utter_gallery/lib/demo/material/text_form_field_demo.dart
+3
-3
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+5
-0
text_form_field.dart
packages/flutter/lib/src/material/text_form_field.dart
+6
-1
form.dart
packages/flutter/lib/src/widgets/form.dart
+14
-15
No files found.
dev/integration_tests/flutter_gallery/lib/demo/material/text_form_field_demo.dart
View file @
7fdd9218
...
...
@@ -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.
_autovalidate
Mode
=
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
:
_autovalidat
e
,
autovalidate
Mode:
_autovalidateMod
e
,
onWillPop:
_warnUserAboutInvalidData
,
child:
Scrollbar
(
child:
SingleChildScrollView
(
...
...
packages/flutter/lib/src/material/dropdown.dart
View file @
7fdd9218
...
...
@@ -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
||
...
...
packages/flutter/lib/src/material/text_form_field.dart
View file @
7fdd9218
...
...
@@ -88,7 +88,7 @@ export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType;
/// },
/// child: FocusTraversalGroup(
/// child: Form(
/// autovalidate
: true
,
/// autovalidate
Mode: 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
,
...
...
packages/flutter/lib/src/widgets/form.dart
View file @
7fdd9218
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment