Replies: 3 comments
-
@bastaware did you manage to find a solution to this? |
Beta Was this translation helpful? Give feedback.
-
Getx doesnt support different data on the same page by navigation 1- Dont navigate, but reload with the different data. ( no navigation and back button ) |
Beta Was this translation helpful? Give feedback.
-
delete your controller |
Beta Was this translation helpful? Give feedback.
-
I've got a search-field in the appbar of my application. It's available on every page of the app. When something is selected in the seach-field, it routes to a named page that loads and displays details about the entity. It is also possible to use the search bar from the details page, which means, that it routes to the same page that it's already on. As the id of the entity is part of the url, the route is actually different and as such everything works. But...
When the page is opened, my GetX controller does some initialization, and on leave it disposes of resources such as TextController.
My problem is that when I navigate to the same page, onClose is not called before leaving which means that the resources are not disposed. Rather it open the 'new' page, calls onInit() then calls onClose() and disposes the resources that are in use.
When the action of the seach-field determines that the currentRoute is already on the details-page, it uses
Get.offNamed('/details', parameters({id: entityId}))
, if it is on another page it simply usesGet.toNamed('/details', parameters({id: entityId}))
I've made a little app the illustrates the problem. The search-field has been replaced by buttons for simplicity.
https://flutlab.io/editor/994c9029-47e9-46e2-a0e6-cfd970b82079
To make it fail, try pressing 'To subpage' button twice.
Notice in the console:
Initialized
Initialized
closed
I was expecting:
Initialized
closed
Initialized
closed
Beta Was this translation helpful? Give feedback.
All reactions