Here are what i am trying
- Page 1 - Ask to select a value.
- Page 2 select the value from the list.
- Once value is selected, navigate back to Page 1
- the selected values should show in the page1.
a code snippet will help.
Here are what i am trying
a code snippet will help.
Copyright © 2021 Jogjafile Inc.
There may be a variety of different solutions...
Here is one approach:
see https://docs.flutter.dev/development/data-and-backend/state-mgmt/simple
What you wrote could be a classic case for "Lifting State Up". You save the value in the parent widget of Page 1 and Page 2, the parent value is a stateful widget. You can pass the value and the handler (selecting the value) to page 1 and page 2 with the constructor (simplest solution). The "value" is stored in the parent widget (exactly: in the State object of the parent) as a state variable.
==== EDIT ====
Sorry, never used GetX and just discovered that GetX state management has the concept of avoiding Stateful Widgets at all.... (don't work with the Flutter toolkit, let's fight it ;-)
Maybe you can try according to this blog post, it shows you a simple solution: (without Obx) https://helloyogita.medium.com/flutter-state-management-with-getx-5b8cad6a33f7
GetX uses GetxController classes to store the state vals.