Skip to content

Navigate to the current route and "reset" the controllers #1

@gatonimo

Description

@gatonimo

Controllers are disposed properly when you navigate to another page. But when you navigate to the current page, seems it doesn't dispose the controller and create a new one.

In GetX this was working when you went to the same page by using the Get.offAll method.

Is there any way to achieve this? I tried deleting and creating the controller manually before navigating to the screen, but for some reason it keeps the previous controller variables in the state and the controller methods such as onInit are not being triggered.

Tried navigating with goNamed replaceNamed and pushReplacementNamed, but the result is the same.

As a workaround, if I navigate to a different page add delay with await Future.delayed(Duration(seconds: 1)), and then navigate again to the current page, it works as expected. But this is not a good solution.

Another workaround would be creating a "reset" method and set all variables to the initial values, then call the "init" and "ready" methods manually. But I would like to avoid this if possible.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions