Repository navigation
FormState validation method to return a Map of the validation status of children FormField(s) #135363
Description
Activity
- addedin triagePresently being triaged by the triage teamPresently being triaged by the triage teamc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilitya: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesteam-designOwned by Design Languages teamOwned by Design Languages teamand removedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Sep 25, 2023 I've come across the same feature request #65573 but without a clear explanation of how this feature adds complexity to the form validation logic. The reasons could be outdated by now.
I've also come across a relatively similar proposal for the
Form.submit()that has been closed for the reason stated here. I don't see those reasons holding for this issue as validation results aren't expected to be serializable.- addedtriaged-designTriaged by Design Languages teamTriaged by Design Languages teamP2Important issues not at the top of the work listImportant issues not at the top of the work list
on Sep 28, 2023 Hi @SharbelOkzan thanks for proposing this new API. Your use-case sounds reasonable and we would welcome a PR which looks like you have already started #135578 so thanks!
Reacted by SharbelOkzan- added a commit that references this issue
on Jan 9, 2024 Closing this as #135578 has been merged.
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.- locked as resolved and limited conversation to collaborators
on Jan 24, 2024
Is there an existing issue for this?
Use case
In a screen containing a relatively long
Formin aSingleChildScrollView, we want to bring the user's attention to the field that may cause a validation error after callingFormState.validate(). The solution was as follows:Now the problem is that where there are multiple widgets that may cause a validation error. There's currently no way to detect which one we should scroll to.
The only solution is to implement a custom validation logic, which defies the whole purpose of using
FormProposal
The proposal is to have another version of the
validatemethod, let's call it,validateGranularly(naming suggestions are very welcome) that returnsMap<Key, bool>, so the above problem will be addressed as follows: