Lets say I have the following two views: products_screen & product_screen,
and the corresponding two controllers: products_controller & product_controller
products_controller query a DB for a list of products, products_screen shows this list of products.
The user can select a product from this list, which takes him to the product_screen where he should be able to see this product details.
I see no need to query the DB again, but rather use the data in products_controller and pass it to product_controller, so that it can be used in product_screen.
What is the right way to do that?
One option I can see here is to pass the productModel to the product_screen (when navigating), and then call the product_controller with that data, but it doesn't feel right...
any other suggestions?
CodePudding user response:
using Getx, you can set arguments property when you want to move from a screen to the next screen like this :
Get.to(YourScreen(), argument: YourDataWhateverItCanbe),
then in the YourScreen() you can call Get.arguments
whenever you need to use it or store in a variable like this :
dynamic theDataFromPreviousPage = Get.arguments;
then use it
Hope this help