safeCurrentRouteName property

String? get safeCurrentRouteName

Get current route name safely

Implementation

String? get safeCurrentRouteName {
  try {
    final RouteMatch lastMatch = routerDelegate.currentConfiguration.last;
    return lastMatch.matchedLocation;
  } catch (e) {
    if (kDebugMode) {
      debugPrint('Error getting current route name: $e');
    }
    return null;
  }
}