Detect pushed routes on Flutter

后端 未结 2 881
长情又很酷
长情又很酷 2021-01-27 21:09

How can I check if a named route is currently on the stack? I do not want to build a new route every time the user pushes a named route that already exists.

Also, is the

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-27 21:37

    Since in my case I had control over the route instance, I went on to investigate the navigator a little further. I found a method that solved my problem:

    navigator.removeRoute(myRoute)

    It does not animate the route out though. The route simply vanishes. For what I need, that is ok since when removeRoute is called, the route to be removed is hidden anyway.

提交回复
热议问题