Flutter, my inputs getting cleared when re-openning page with bottomnavbar

Viewed 29

I have a bottomnavigation bar and 3 pages. I move between these 3 pages with Get.to() in bottomnavigationbar. I have some input fields in one of those pages. I write inputs then I go to another page with bottomnavigationbar and then I reopen that page again but every input I wrote is cleared. I want to save the state of that page or with other words, I don't want these inputs to get cleared when moving to another page. How can I achieve it?

1 Answers

Because you are using Get.to(), meaning you using get libbrary.

In this case you need to put your TextEditingController to your GetxController and binding in the page that contains your bottomnavigationbar. Now the parent page was hold the GetxController who will store your textfield state instead of widget state.

Or just adding permanent: true to your controller binding.

Related