setNavigationActive method

void setNavigationActive(
  1. bool active
)

Sets the navigation active state to determine service behavior

Implementation

void setNavigationActive(bool active) {
  _isNavigationActive = active;
  debugPrint("[DEBUG] Navigation active state set to: $_isNavigationActive at ${DateTime.now()}");

  // If navigation is active and we're not using foreground service yet, start it
  if (_isNavigationActive && _useForegroundService && _foregroundLocationSubscription == null) {
    _startForegroundLocationService();
  }
  // If navigation is no longer active and we were using foreground service, consider stopping it
  else if (!_isNavigationActive && _foregroundLocationSubscription != null) {
    // Only stop foreground service if explicitly requested, to maintain location updates
    // when app goes to background but navigation still needs to continue
    debugPrint("[DEBUG] Navigation deactivated but keeping foreground service running");
  }
}