理解Flutter中路由移动的原理

Understanding the principles of moving along routes in Flutter

我有路线:

'/home'
'/home/nav_one'
'/home/nav_one/nav_two'
'/home/contacts'
'/home/contacts/description'

并且完成了转换:

'/home' -> '/home/nav_one' -> '/home/nav_one/nav_two' -> '/home/contacts/description'

命令return: Navigator.pop(): 要 '/home/nav_one/nav_two''/home/contacts'?

如果是第一个选项,那为什么还要写这些相同的路由,为了阅读和理解方便?

假设这些是路线名称并且您已经Navigator.pushNamed()查看屏幕,答案是

'/home/nav_one/nav_two'

这些路由名称只是标识符,因此您可以像这样命名它们,

'/home'
'/nav_one'
'/nav_two'
'/contacts'
'/description'

为了您自己的方便。