FormField should autovalidate only if its content was changed (fixed)#59766
FormField should autovalidate only if its content was changed (fixed)#59766fluttergithubbot merged 30 commits intoflutter:masterfrom
Conversation
# Conflicts: # packages/flutter/lib/src/material/text_form_field.dart # packages/flutter/test/material/dropdown_form_field_test.dart # packages/flutter/test/material/text_form_field_test.dart
chunhtai
left a comment
There was a problem hiding this comment.
Assuming nothing change from previous PR, LGTM except the formatting nit
justinmc
left a comment
There was a problem hiding this comment.
Thanks for opening up a new PR to get this to work. A few question and some indentation corrections below.
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
It looks like the branch may still out of date, are you sure you have the latest from the master? |
There is new updates. Let me update this branch again. |
|
🎉 Congrats! Thanks again for all the persistence in getting this PR ready. An API like this is tricky to get right. Let's keep an eye on how Flutter developers are using it as it rolls out. |
Thank you. I still interested in improve this feature. And I will do that. |
|
Hi there!, thank you for the effort on this project, I have a few questions about TextFormField class and the version of these changes: 1. Has the property: I did the mistake of upgrade the version I had because the notification on the IDE was really annoying (currently I can't remember the previous version, but after updating the The current version of flutter I have is the following:
Flutter 1.20.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision bbfbf1770c (3 weeks ago) • 2020-08-13 08:33:09 -0700
Engine • revision 9d5b21729f
Tools • Dart 2.9.1
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.20.2, on Mac OS X 10.15.6 19G2021, locale en-HN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 4.0)
[✓] IntelliJ IDEA Community Edition (version 2020.2.1)
[✓] VS Code (version 1.48.2)
[✓] Connected device (1 available)
• No issues found!2. Which version of flutter were these changes merged? In the changed files I can see that the property Could you give a hand to know what can I do because if not I will refactor the logic of some features already done. Thanks! |
|
It is not release to stable yet, you can switch to master channel and will be able to use this new API |
|
Oh!, understand it. |
|
I couldn't find this autovalidatemode field in the TextFormField. Following is my flutter doctor output: ` [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [√] Android Studio (version 4.0) [√] VS Code, 64-bit edition (version 1.48.2) [√] Connected device (1 available) • No issues found! When it will be added to stable release? |
|
It is not yet on stable! |
|
@EffyCoder & @pedromassango I fixed my issue using build(BuildContext context) {
return Container(
TextFormField(
autovalidate: focusNode.hasFocus,
)
);
}You can do more stuffs with this approach, and it's working in the same way before it was. |
Last week I was thinking of adding this feature. @chunhtai @justinmc My only concern it just that autovalidateMode.hasFocus will only be used on single form fields (FormField, TextFormField, etc..) and not on the Form widget. We have make it clear that it will have no effect on the Form widget, but this may not be the best thing to do. Do you have any thing in mind about this? |
|
They can achieve the same result with return Container(
TextFormField(
autovalidateMode: focusNode.hasFocus ?? AutovalidateMode.always :AutovalidateMode.disabled
)
);We should not expend the mode unless there is a mode that cannot be achieve with current API and/or we have a lot of use cases. |
|
I just updated my flutter_form_builder package. First off, thank you for implementing this feature!! Why is the type of autovalidateMode dynamic though? Also, my IDE can't find "AutovalidateMode.always" etc EDIT: |

Description
I propose to auto-validate
FormFieldonly if its content was changed since its prevents end users to see validation errors even without changing the field's content.Related Issues
Fixes: #56363
Fixes: #18885
Fixes: #15404
Fixes: #36154
Fixes: #48876
Tests
I added the following test cases:
autovalidate parameter is still used if true;
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read [Handling breaking changes].