How to get current route path in Flutter?

后端 未结 4 1952
长情又很酷
长情又很酷 2020-12-02 10:13

While implementing persistent bottom bar, previous route need to be restored when a button in the bottom bar was clicked.

When a button in the bottom bar is clicked

4条回答
  •  隐瞒了意图╮
    2020-12-02 10:47

    Posting this answer mainly for archival purposes, but as @ikben mentioned, one way to get the current route, and all its properties, is ModalRoute.of(context). This returns a ModalRoute, which despite its name, applies to most Navigator.push calls, not just showDialog. Helpful properties include Route.settings, Route.navigator, and Route.isFirst.

提交回复
热议问题