Hi I am running into an issue where I am unable to save the state of the DropdownButton (the text shown in the Dropdown Button itself, which is the value that I have selected). I am using GetX for state navigation.
Due to the way my code has been structured, when I navigate from one screen to a second one, and wish to navigate back, I am utilising Get.to(First()
instead of Get.back()
.
Here is my logic:
- I will save the value the user has selected from the DropdownButton into SharedPreferences. This value will also be immediately shown to the user on the button itself due to the nature of the button.
- When user navigates away (e.g. he is now on the second screen), and visits first screen again, I will load the selected value from SharedPreferences and construct the DropdownButton item such that this value will be shown at the top.
The issue I am facing: Retrieving data from SharedPreferences is asynchronous, so I don't know how to construct the FirstScreen again while I am waiting for data to be retrieved from SharedPreferences. Could anyone help me out? Thank you!