getCurrentNavigatorRoute static method
Trick explained here: https://github.com/flutter/flutter/issues/20451
Note ModalRoute.of(context).settings.name
doesn't always work.
Implementation
static Route? getCurrentNavigatorRoute(BuildContext context) {
Route? currentRoute;
Navigator.popUntil(context, (route) {
currentRoute = route;
return true;
});
return currentRoute;
}