Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

routing - 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.

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.

How to get current route path in Flutter, when the routing is rewinding to root?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This should give you the exact route name

ModalRoute.of(context).settings.name

if you use Navigator.popuntil.. check this other answer out by Rémi Rousselet https://stackoverflow.com/a/50817399/5921185


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...