In my Flutter application I need to know the current path to avoid pushing the same path twice.
I found that I can use the following code:
ModalRoute.of(context).settings.name
It works, but only for the main Navigator.
Since I have a second Navigator in my app that I target with a GlobalKey, how can I access its current path?
I tried like this:
ModalRoute.of(HomePage.navigatorKey.currentContext).settings.name
But it returns the main route.