detectInitialRoute method

void detectInitialRoute(
  1. NavigatorState? navigatorState
)

Try to detect initial route from Navigator context This should be called after the NavigatorState is available

Implementation

void detectInitialRoute(NavigatorState? navigatorState) {
  if (!_isActive || navigatorState == null) return;

  try {
    // Get current route from Navigator if available
    final context = navigatorState.context;
    final route = ModalRoute.of(context);

    if (route != null && _currentRouteName == null) {
      _currentRouteName = _extractRouteName(route);
      ObslyLogger.debug('🎯 Detected initial route: $_currentRouteName');
    }
  } catch (e) {
    ObslyLogger.debug('Could not detect initial route: $e');
  }
}