Home > Blockchain >  How to edit a textField using setState?When i press the edit button i have to make a setState with a
How to edit a textField using setState?When i press the edit button i have to make a setState with a

Time:10-06

enter image description here This is a ss of the code:

So, i have to make a setState with a variable, when the var is in the if condition it has to call get content.

CodePudding user response:

Have you tried

  • Using onChange(String? value) method in the TextField
  • If you want to setState inside a pop up menu use a statefulbuilder to setState inside pop up or a dialog

In most cases you can call setState((){}); inside the onChanged method to update state based on every character the user enters. Else you can use onEditing complete to do the same.

The best way to self debug is to hover over the class object ( in this case TextField) to see it's documentation to get an idea of how you can apply your logic.

CodePudding user response:

You should think about that, you update the controller of the TextField rather than the TextField itself. Update the value of the controller of the textField it will auto-update the value of textField. Please check with the TextEditingController, create an instance of TextEditingController, and pass it as a controller parameter in TextField.

  • Related