Skip to content

[Bug]: Re-routing is not working in release mode with ios 26.2 version #595

@rajeshbdabhi

Description

@rajeshbdabhi

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

On a real iOS device running iOS 26.2, the automatic rerouting feature fails to update the route during navigation.

Once navigation starts and the initial route is drawn on the map, no new route is generated if the user ignores the drawn route and travels in a different direction or the wrong side of the planned path.

Note: This issue occurs specifically in release mode on iOS 26.2 or later versions.

Flutter version

3.32.8

Package version

0.8.0

Native SDK versions

  • I haven't changed the version of the native SDKs

Flutter Doctor Output

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.32.8, on macOS 26.1 25B78 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 26.2)
! CocoaPods 1.15.0 out of date (1.16.2 is recommended).
CocoaPods is a package manager for iOS or macOS platform code.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/to/platform-plugins
To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.2)
[✓] VS Code (version 1.107.1)
[✓] Connected device (3 available)
[✓] Network resources

! Doctor found issues in 1 category.

Steps to reproduce

  1. Start navigation from one location to another destination.
  2. Begin traveling along a different road, in the wrong direction, or deviate from the suggested route.
  3. The route does not update automatically.

Expected vs Actual Behavior

The route should always automatically update based on the device's current location while navigation is started and running.

Code Sample

final accepted = await GoogleMapsNavigator.showTermsAndConditionsDialog(
  'terms_conditions'.tr,
  'hich'.tr,
);

if (!await GoogleMapsNavigator.isInitialized()) {
  print("startGoogleNavigationLocation: initialize");
  await GoogleMapsNavigator.initializeNavigationSession(
    taskRemovedBehavior: TaskRemovedBehavior.quitService,
  );
}

if (GetPlatform.isIOS) {
  await GoogleMapsNavigator.allowBackgroundLocationUpdates(true);
}

// Sort trip models by distance from current location
List<NavigationWaypoint> waypointsRoutes = [];
if (mapLocation != null) {
  tripModelList.sort((a, b) {
    final aLat = rideReachEnd ? (a.dropOffLat ?? 0.0) : (a.pickUpLat ?? 0.0);
    final aLng = rideReachEnd ? (a.dropOffLng ?? 0.0) : (a.pickUpLng ?? 0.0);
    final bLat = rideReachEnd ? (b.dropOffLat ?? 0.0) : (b.pickUpLat ?? 0.0);
    final bLng = rideReachEnd ? (b.dropOffLng ?? 0.0) : (b.pickUpLng ?? 0.0);

    final aDistance = Utils.getDistanceInMeter(
      mapLocation!,
      LatLng(latitude: aLat, longitude: aLng),
    );
    final bDistance = Utils.getDistanceInMeter(
      mapLocation!,
      LatLng(latitude: bLat, longitude: bLng),
    );

    return bDistance.compareTo(aDistance); // Sort ascending by distance
  });
}

const double minDistanceMeters = 5.0; // Duplicate tolerance threshold

// Build waypoints list (deduplicated)
tripModelList.forEach((tripData) {
  double? lat, lng;
  String? titleDest;

  if (rideReachEnd && Utils.tripStatusAfterStarted.contains(tripData.tripStatus)) {
    lat = tripData.dropOffLat ?? 0.0;
    lng = tripData.dropOffLng ?? 0.0;
    titleDest = tripData.dropOffLocation ?? "";
  } else if (!rideReachEnd && Utils.tripStatusBeforeStarted.contains(tripData.tripStatus)) {
    lat = tripData.pickUpLat ?? 0.0;
    lng = tripData.pickUpLng ?? 0.0;
    titleDest = tripData.pickUpLocation ?? "";
  }

  if (lat != null && lng != null && titleDest != null) {
    final newPoint = LatLng(latitude: lat, longitude: lng);

    // Check for duplicates within tolerance
    final isDuplicate = waypointsRoutes.any((wp) {
      final existing = wp.target!;
      final distance = Utils.getDistanceInMeter(existing, newPoint);
      return distance < minDistanceMeters;
    });

    if (!isDuplicate) {
      waypointsRoutes.add(
        NavigationWaypoint.withLatLngTarget(
          title: titleDest,
          target: LatLng(latitude: lat, longitude: lng),
        ),
      );
    }
  }
});

// Fallback to single destination if no waypoints found
if (waypointsRoutes.isEmpty) {
  waypointsRoutes.add(
    NavigationWaypoint.withLatLngTarget(
      title: title,
      target: destinationLocation,
    ),
  );
}

final Destinations msg = Destinations(
  waypoints: waypointsRoutes,
  displayOptions: NavigationDisplayOptions(
    showDestinationMarkers: false,
    showStopSigns: true,
    showTrafficLights: true,
  ),
  routingOptions: RoutingOptions(
    routingStrategy: NavigationRoutingStrategy.defaultBest,
    travelMode: NavigationTravelMode.driving,
    alternateRoutesStrategy: NavigationAlternateRoutesStrategy.none,
    avoidFerries: true,
  ),
);

// Handle already running guidance
if (await GoogleMapsNavigator.isGuidanceRunning()) {
  print("startNavigation: guidance is running");
  _logFn("startNavigationGuidanceAlreadyRunning", {});

  app.getAppPreferences().setNavigationStatus(isStarted: true);
  await mapController?.setNavigationUIEnabled(true);

  await GoogleMapsNavigator.stopGuidance();
  await GoogleMapsNavigator.setDestinations(msg);
  await GoogleMapsNavigator.startGuidance();

  await _setRideMakers(iconPath);
  return;
}

// Fresh navigation setup
await GoogleMapsNavigator.clearDestinations();
await mapController?.setNavigationUIEnabled(true);

final NavigationRouteStatus status = await GoogleMapsNavigator.setDestinations(msg);
print(
  "startNavigation: status: ${status}, ${tripModelList.length}, ${waypointsRoutes.length}",
);
_logFn("startNavigationSetDestinations", {"status": status.name});

if (status == NavigationRouteStatus.statusOk) {
  // Configure map UI
  await mapController?.setNavigationFooterEnabled(false);
  await mapController?.setRecenterButtonEnabled(true);
  
  if (GetPlatform.isIOS) {
    await mapController?.setMyLocationEnabled(false);
  } else {
    await mapController?.setMyLocationEnabled(true);
  }
  
  await mapController?.setTrafficIncidentCardsEnabled(true);
  await mapController?.setSpeedometerEnabled(false);
  await mapController?.setReportIncidentButtonEnabled(false);
  await mapController?.setNavigationTripProgressBarEnabled(false);

  await GoogleMapsNavigator.startGuidance();
}

Additional Context

No response

Metadata

Metadata

Assignees

Labels

triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions