getCurrentNavigatorRouteName static method
Trick explained here: https://github.com/flutter/flutter/issues/20451
Note ModalRoute.of(context).settings.name
doesn't always work.
Implementation
static String? getCurrentNavigatorRouteName(BuildContext context) =>
getCurrentNavigatorRoute(context)!.settings.name;