Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returns to an existing page and cannot refresh the controller #3093

Open
quentin996007 opened this issue May 11, 2024 · 3 comments
Open

Returns to an existing page and cannot refresh the controller #3093

quentin996007 opened this issue May 11, 2024 · 3 comments
Assignees

Comments

@quentin996007
Copy link

My current page structure is A -> B (Chat page) -> C -> D (Select New Contact page), when I have done some operations using D page, I want to go back to B page and let the controller of B be completely destroyed and recreated, C and D pages are no longer needed.
I tried to use the following code and instead of destroying and then creating the controller, it is created and then destroyed:

    Get.offNamedUntil("B", (route) => route.settings.name == "A");

How can I solve this problem? Currently I have implemented it in a less than elegant way and I would like to get the elegant and correct answer.

example:

    Get.until((route) => route.settings.name == Routes.A);
    Future.delayed(const Duration(milliseconds: 500), () {
      Get.toNamed(Routes.B);
    });
@allasca
Copy link

allasca commented May 25, 2024

you need create controller for every page, C , B and D controller will destroyed if you leave the page, and if you back to page B, controller B will be init again.
use final c = Get.put(BController) below Widget build

@quentin996007
Copy link
Author

@allasca The page I generated using get_cli does a lazyPut of the controller in the binding file。
Get.offNamedUntil("B", (route) => route.settings.name == "A");
but the page B controller is not properly destroyed and created again

@allasca
Copy link

allasca commented May 28, 2024

@quentin996007 get.offamed will destroyed the last page and remove it from stack, and you cant go back. Try use get.tonamed. sorry I ma not using get_cli anymore, little forgot about it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants