If the user clicks on back from homepage, he should go to product details page.
When I am using Get.tonamed(Routes.Home) , Getx is creating a new instance of homepage.
If I remove pages in stack and go back to homepage, I am not able to take user to the details page wien the user presses the back button.
I want to take user to details page when he clicks on back button.
Use Get.ofAll(Home());
to avoid creating new instance of HomePage
this will remove all the stacked pages in the Navigation Stack
When you go from Home -> Products -> Details -> Home.
Navigator creates a stack, so that you can go back to the top of the stack when a page is popped
| Home | 👈 Top of the stack
| Details |
| Products |
| Home |
|__________|
Home
?To access the Home you have to pop all the elements in the stack and reach Home
1.Popping Details Screen
_> Pop Details Page from the stack
| ( |
| Details |
| Products |
| Home |
|__________|
2.Popping Products Screen
_> Pop Products Page from the stack
| ( |
| Products |
| Home |
|__________|
Now the stack:
| |
| Home | 👈 Top of the stack
|__________|
Details Page
now ?No, you cannot go back to DetailsPage
because you have popped the DetailsPage
,ProductsPage
to reach Home