sorry in advance if i didnt describe my question clearly:
I have several pages made by PageView.builder
, while swiping these pages on main screen left and right, I found their initState
is already working, and GetXController inside are also loading their data. I use Get.delete<Controller>
while clicking back button and coming back to main screen to remove these data.
However, the state and data will bring back to main screen if I didnt activate Get.delete<Controller>
, and therefore next time I come to this page, the state of page will be not default, for instance the button still keep pressed status.
So my question is how to prevent page.builder to build the widget before I come inside to this page, or how to delete getxcontroller if I am not in this page. Thanks a lot!
CodePudding user response:
Try resetting the GetX by calling
Get.reset();
--> this will re-initialize controllers
Alternatively calling
Get.put(ControllerName());
in a build method will re-initialize the controller