Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 548
Kyaw Tun Avatar asked Sep 29 '17 07:09

Kyaw Tun


People also ask

How do you get navigation stack in flutter?

Flutter Navigator class The Navigator class provides all the navigation capabilities in a Flutter app. Navigator provides methods to mutate the stack by a push to stack or by popping from the stack. The Navigator. push method is for navigating to a newer page and Navigator.


1 Answers

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

like image 69
ikben Avatar answered Oct 23 '22 22:10

ikben