If there are multiple textfields in a screen in flutter which are edited to suitable text and from that screen when the user moves to other screen and comes back to the same screen where the text fields are. How should I make sure that those textfields have the same text which was entered in the fields and not removed in the screen.
TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Enter a search term'
),
);
You should store the input text in a variable so if you return to that screen either it will retain state or you can rebuild but since you have the text stored in a variable you will be able to still show that to user. Use TextEditingController
and set its text
property accordingly
For Example,
TextEditingController _controller = TextEditingController();
Then
_controller.text = <variable>
Take a look at this post