Home > database >  How to deactivate form key in text form field?
How to deactivate form key in text form field?

Time:01-03

enter image description here

Here, I have taken email and password in text form field. If user do not fill any details within that and click on log in that time error message shows that plz enter email and password in text form field. Now the problem is when user click on login without info and then click on forget password it will show error of empty data and redirect on forget password screen. but when user come back to login page that message will be show as it is like before. my pont is when user come back to login screen that time all the errors and info will be clear as like init state. How do I do it ?

CodePudding user response:

this can you help out

TextFormField(
  key: _formKey,
  enabled: false,  // Deactivate the form key
  decoration: InputDecoration(
    hintText: 'Enter some text',
  ),
  validator: (value) {
    if (value.isEmpty) {
      return 'Please enter some text';
    }
    return null;
  },
)

CodePudding user response:

controller.loginFormKey.currentState!.reset();

Just add this line on click of forget password. It will reset form state.

  • Related