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
I need to reset all my form fields even after I "submit" the form...
If I never call onPressSubmitthen I can reset the form.
But as soon as I save the form, it does nothing more than getting initialValues, but those ones are now the values submitted and no more the initial values...
Why setAttributeValue does not change the display ?
What do I do wrong ?
How to reset or set a field value after build ?
Thank you
void onPressSubmit() async {
setState(() => {err.reset()});
if (_formKey.currentState.saveAndValidate()) {
try {
final data = _formKey.currentState.value;
final loginProps = LoginModel(
login: data['login'].toString(),
password: data['password'].toString());
final auth = Provider.of<Authentication>(context, listen: false);
final response = await auth.login(loginProps);
widget?.onSuccess(context, (response as AuthenticationModel).token);
} catch (e) {
setState(() {
_formKey.currentState.reset();
_formKey.currentState.setAttributeValue('login', '');
_formKey.currentState.setAttributeValue('password', '');
err.message = e?.message as String;
});
widget?.onError(context, '', e.message as String);
}
}
}
_onTapPasswordReminder() {
_formKey.currentState.reset();
_formKey.currentState.setAttributeValue('login', '');
_formKey.currentState.setAttributeValue('password', '');
setState(() {
err.reset();
});
widget.onTapPasswordReminder();
}
The text was updated successfully, but these errors were encountered:
Hi,
I need to reset all my form fields even after I "submit" the form...
onPressSubmit
then I can reset the form.Thank you
The text was updated successfully, but these errors were encountered: