getCurrentNavigatorRouteName static method

String? getCurrentNavigatorRouteName(
  1. BuildContext context
)

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;