如何在 Flutter 中获取当前路线路径? [英] How to get current route path in Flutter?
问题描述
While implementing persistent bottom bar, previous route need to be restored when a button in the bottom bar was clicked.
当点击底部栏中的按钮时,其当前路由路径(/a/b/c) 保存,点击按钮恢复之前保存的路线.
When a button in the bottom bar is clicked, its current route path (/a/b/c) is saved and previously saved route is restored according to the button click.
从概念上讲,用户会将每个按钮视为一个工作区,其状态永远不会丢失(包括返回堆栈).用户可以安全地从一个工作区切换到另一个工作区.
Conceptually user will think each button as a workspace and its state is never get lost (including back stack). User can safely switch from one workspace to another.
如何在Flutter中获取当前路由路径,当路由是rewinding to root?
How to get current route path in Flutter, when the routing is rewinding to root?
推荐答案
这应该会给你确切的路线名称
This should give you the exact route name
ModalRoute.of(context).settings.name
如果您使用 Navigator.popuntil .. 检查 Rémi Rousselet 的其他答案 https://stackoverflow.com/a/50817399/5921185
if you use Navigator.popuntil.. check this other answer out by Rémi Rousselet https://stackoverflow.com/a/50817399/5921185
这篇关于如何在 Flutter 中获取当前路线路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!