4

I am a recent flutter developer. How can i get current route name?I am having a common list view in two different routes. I want to hide certain properties in list based on routes.

Please help me..

Sana Afreen
  • 157
  • 2
  • 3
  • 9
  • this may help you : https://stackoverflow.com/questions/46483949/how-to-get-current-route-path-in-flutter – haresh Dec 31 '19 at 10:14

2 Answers2

11

try this:

var route = ModalRoute.of(context);

if(route!=null){
  print(route.settings.name);
}
Mehrdad
  • 1,477
  • 15
  • 17
0

path:

Router.of(context).routeInformationProvider?.value.location

name:

ModalRoute.of(navKey.currentContext).settings.name.
Ced
  • 15,847
  • 14
  • 87
  • 146