skip to Main Content

I have a Textformfield in one file and a Button in another file. I need to import the Form key from the Textformfield into the button file so I can use it to alter the text field. However, it won’t recognize the Form key even if I import the file it’s in. What am I supposed to?

2

Answers


  1. I tried to implement exactly the same as you described. But couldn’t implement it.
    Cause, Global form key don’t hold it’s state on another file.
    The solution you can follow is build a reusable text field and pass the form validation as argument. It work fine.

    Login or Signup to reply.
  2. ->Make sure the file containing the TextFormField and its form key is exported properly.

    ->Import the file with the TextFormField into the file where the Button is located using the correct import statement.

    ->Ensure that the form key is defined as a global variable or part of the class so that it is accessible outside the file.

    ->When using the form key in the file with the Button, reference it using the correct import path and variable name.

    If the issue persists, check for any typos or errors in your code and ensure that the file structure and import statements are correct.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search