Writing multiple text editing controller for multiple texts makes the code so long . Does anyone know how to write only one text editing controller and provide multiple texts in flutter ??
CodePudding user response:
create one TextEditingController
create a map containing all your different text values
encode the map so that it can be passed to TextEditingController
pass the encoded map to the TextEditingController for it's text parameter
update the relevant key in the map as required when the state changes
CodePudding user response:
Having multiple controllers won't slow down your code. And it's always better to avoid any misconfigurations for your text. So it's better to use different controllers for each text field as you could perform functions on specific text field data