Uh oh!
There was an error while loading. Please reload this page.
Form fields onChange callback should be called on reset - #134295
Conversation
90eea5c to
ba88062Compareba88062 to
2af641fCompareThere was a problem hiding this comment.
Should we still call this if the value did not change?
There was a problem hiding this comment.
Same for other FormFields.
There was a problem hiding this comment.
I chose not to add such a check in order to be consistent with FormState.reset which (indirectly) call the Form.onChanged callback without checking if field values have changed.
I also checked that DropdownButton.onChanged is called when the same entry is selected.
Maybe we should consider this is another issue/PR? I don't know if this was done on purpose.
There was a problem hiding this comment.
Can this be made a doc template and reused.
There was a problem hiding this comment.
Probably, I upated the PR accordingly.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Renzo-Olivares
left a comment
There was a problem hiding this comment.
Thanks for the contribution @bleroux. Just had a few comments.
2af641f to
28efbeeCompare28efbee to
fc3af56CompareThere was a problem hiding this comment.
nit: TestFormField -> TextFormField. I think
There was a problem hiding this comment.
Thanks for pointing this out!
Renzo-Olivares
left a comment
There was a problem hiding this comment.
LGTM w/ small nit. Thanks for fixing this @bleroux!
914a2fa to
57c90ccCompare57c90cc to
0ec68a8Compare## Description This PR fixes form fields in order to call the `onChange` callback when the form is reset. This change is based on the work done in flutter#123108. I considered adding the `onChange` callback to the `FormField` superclass but it would break existing code because two of the three subclasses defines the `onChange` callback with `ValueChanged<String>?` type and the third one defines it with `ValueChanged<String?>?`. ## Related Issue Fixesflutter#123009. ## Tests Adds 3 tests.
Description
This PR fixes form fields in order to call the
onChangecallback when the form is reset.This change is based on the work done in #123108.
I considered adding the
onChangecallback to theFormFieldsuperclass but it would break existing code because two of the three subclasses defines theonChangecallback withValueChanged<String>?type and the third one defines it withValueChanged<String?>?.Related Issue
Fixes#123009.
Tests
Adds 3 tests.