updateLocation method

Future<void> updateLocation(
  1. RaliPosition newLocation
)

//////////// //////////// Updates the current location and recalculates navigation state

Implementation

// II.F - Location and Progress Updates
///////////////
/// Updates the current location and recalculates navigation state
Future<void> updateLocation(RaliPosition newLocation) async {
  _currentLocation = newLocation;

  // Don't process updates if navigation is paused
  if (_isPaused) return;

  if (_state == NavigationStatus.active && _currentRoute != null) {
    // Update the current step based on location
    _updateCurrentStep(newLocation);

    // Calculate progress along the route
    _progress = _calculateProgress(newLocation);

    // Check if we need to reroute
    await _checkReroute(newLocation);

    // Check if we've arrived at the destination
    if (_progress >= 0.99) {
      _state = NavigationStatus.arrived;
    }

    // Save navigation state for persistence
    await _saveNavigationState();

    notifyListeners();
  }
}