selectRoute method
- int index
Selects a different route from the alternatives
Implementation
void selectRoute(int index) async {
if (index < 0 || _alternativeRoutes.isEmpty || index >= _alternativeRoutes.length) {
print('Invalid route index: $index');
return;
}
try {
_selectedRouteIndex = index;
_currentRoute = _alternativeRoutes[index];
_currentStepIndex = 0;
_progress = 0.0;
// Recalculate cumulative distances
_calculateCumulativeStepDistances();
// Save route state for persistence
await _saveNavigationState();
notifyListeners();
} catch (e) {
print('Error selecting route: $e');
}
}