Closed mwoelk closed 2 weeks ago
Just realized that form itself has an onChanged
that is called whenever a field changes. It could easily be listened to and just set a flag accordingly when any field has changed.
Closing because not an issue anymore.
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.
Use case
Sometimes we want to check if a user has interacted with a form so we can offer him the option to save when e.g. popping the route. Currently this can be quite cumbersome to do by listening to
onChange
events of every single field and updating some state.Form
has a private flag for this,_hasInteractedByUser
, which could provide the required information.Proposal
There already was a similar issue to expose this method for
FormField
. The proposal would be to do the same forForm
: expose a boolean getter for the value of _hasInteractedByUser.This way, it could be easily accessed via a key in e.g. a pop handler.