You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add TextFormField validation states (dirty, touched, etc) #18885
Another feature request:
At the moment TextFormField allows to use autovalidate activated or deactivated which is nice.
The "problem" is that if autovalidate is active, it validates the initial state of the input right away, marking a field as invalid when a user opens first time a login page for example - which does not look very nice.
A possible solution would be using additional states. Something like:
field is empty and untouched
field is empty but user wrote something before (and deleted it again)
Workaround - add a bool touched=false to the form. Set to true when submitting the form and validation fails. Set audovalidate: touched on each form field. The initial editing will be clean, when the user is fixing validation issues the form fields will autovalidate.
Reacted by Ezra, Alejandro , Yumin Chen and Zhuoran (John) Li
+1 Angular has this feature, as well as many other Frameworks. Therefore, Flutter should have this, especially a way to check if a field is "dirty" and only mark that field as invalid.
Hi, I'm removing the a: annoyance tag. Not that I think this omission in functionality isn't annoying. I just try to reserve the a: annoyance tag only for issues with existing stable features (see definition).
There is some great discussion about this problem in #48155 for anyone that's interested. My best current solution is to use composition like in #48155 (comment), but I'm keeping this issue open in hope of a deeper solution, or at least some docs/communication improvements.
Workaround - add a bool touched=false to the form. Set to true when submitting the form and validation fails. Set audovalidate: touched on each form field. The initial editing will be clean, when the user is fixing validation issues the form fields will autovalidate.
Is it posible to set autoValidate to true in onChaged() of every field?
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
pdefuns commentedon Sep 21, 2018
+1
would be nice to have autovalidate but not from beginning on when the user didn't touch the field yet.
larssn commentedon Jul 5, 2019
This is pretty crucial for any Framework.
liri2006 commentedon Jul 6, 2019
+1
Would be great to have this out of the box!
GenuineRex commentedon Aug 8, 2019
+1
The closer Flutter comes to feature parity with Angular, the easier it is to move between the frameworks.
GenuineRex commentedon Aug 8, 2019
Workaround - add a bool touched=false to the form. Set to true when submitting the form and validation fails. Set audovalidate: touched on each form field. The initial editing will be clean, when the user is fixing validation issues the form fields will autovalidate.
Reprevise commentedon Sep 8, 2019
+1 Angular has this feature, as well as many other Frameworks. Therefore, Flutter should have this, especially a way to check if a field is "dirty" and only mark that field as invalid.
filiph commentedon Mar 26, 2020
Hi, I'm removing the
a: annoyancetag. Not that I think this omission in functionality isn't annoying. I just try to reserve thea: annoyancetag only for issues with existing stable features (see definition).justinmc commentedon Apr 14, 2020
There is some great discussion about this problem in #48155 for anyone that's interested. My best current solution is to use composition like in #48155 (comment), but I'm keeping this issue open in hope of a deeper solution, or at least some docs/communication improvements.
nateshmbhat commentedon May 5, 2020
@filiph @justinmc Please review this PR #56132
it seems like a neat fix for the first render issue.
yalva commentedon May 16, 2020
Is it posible to set autoValidate to true in onChaged() of every field?
github-actions commentedon Aug 15, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.