-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Use case
I'm extending the FormFieldState class to create a custom type of form. I've overridden the save method to call another method in the codebase, whenever save is triggered from the wrapping Form. I only want to call this other method if the field has been interacted with.
FormField has a private flag for this, _hasInteractedByUser, which could provide the required information. A way to currently solve this is to override didChange and reset to keep track of my own boolean flag.
Proposal
I would like FormFieldState to expose a boolean getter for the value of _hasInteractedByUser. I see two cases in which this could be useful.
- When accessing the
FormFieldStatevia a key.
final key = GlobalKey<FormFieldState<String>>;
TextFormField(
key: key,
),
final changed = key.currentState!.hasInteractedByUser;- When extending
FormFieldState.
@override
void save() {
super.save();
if(hasInteractedByUser) {
doSomethingAwesome();
}
}karelVanGeerdeghom, AntonBaeckelandt, JeffreyDeNeve, mdewilde and tbousson
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team