Skip to content

[Bug]: Remaining infos lost after start&stop guidance #699

@bderrien

Description

@bderrien

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

getCurrentTimeAndDistance() no longer works correctly after starting and then stopping guidance when listening to setOnRemainingTimeOrDistanceChangedListener() or setOnRouteChangedListener().

Here is the issue:

  • When guidance is not started, switching to an alternative route correctly updates the remaining time and distance.
  • When guidance is running, switching to an alternative route also works as expected.
  • However, after stopping guidance, if we switch to an alternative route:
    • iOS: only the remaining distance is updated; the remaining time does not change.
    • Android: neither the remaining time nor the remaining distance is updated.

It looks like route changes are no longer fully propagated after guidance has been stopped.

Flutter version

3.38.5

Package version

0.9.2

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.38.5, on macOS 26.5 25F71 darwin-arm64, locale en-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
[✓] Xcode - develop for iOS and macOS (Xcode 26.4)
[✓] Chrome - develop for the web
[✓] Connected device (5 available)
[✓] Network resources

Steps to reproduce

Use the patch on the example project:

  1. Go to "Navigation".
  2. Add a destination that provides multiple route alternatives.
  3. Start guidance.
  4. Stop guidance.
  5. Tap an alternative route polyline.

Expected vs Actual Behavior

Expected result:
The remaining time and distance should be updated.

Actual result:
(iOS) Only the distance is updated.
(Android) Neither the time nor the distance is updated.

Code Sample

use this patch to reproduce bug easily

diff --git forkSrcPrefix/example/lib/pages/navigation.dart forkDstPrefix/example/lib/pages/navigation.dart
index df1a176744bcc12211aaa10e797c924d761539d7..3fb7ba8d10d84fd77aec67b7e1cc479018bac72f 100644
--- forkSrcPrefix/example/lib/pages/navigation.dart
+++ forkDstPrefix/example/lib/pages/navigation.dart
@@ -124,7 +124,7 @@ class _NavigationPageState extends ExamplePageState<NavigationPage> {
   bool _errorOnSetDestinations = false;
   bool _navigatorInitialized = false;
   bool _guidanceRunning = false;
-  bool _showRemainingTimeAndDistanceLabels = false;
+  bool _showRemainingTimeAndDistanceLabels = true;
   SimulationState _simulationState = SimulationState.notRunning;
   NavigationTravelMode _travelMode = NavigationTravelMode.driving;
   final List<NavigationWaypoint> _waypoints = <NavigationWaypoint>[];
@@ -509,7 +509,7 @@ class _NavigationPageState extends ExamplePageState<NavigationPage> {
     });
   }
 
-  void _onRouteChangedEvent() {
+  void _onRouteChangedEvent() async {
     if (!mounted) {
       return;
     }
@@ -520,9 +520,18 @@ class _NavigationPageState extends ExamplePageState<NavigationPage> {
       // Continue simulation with the new route as soon as it's available.
       _startSimulation();
     }
+
+
     setState(() {
       _onRouteChangedEventCallCount += 1;
     });
+
+    final NavigationTimeAndDistance timeAndDistance = await GoogleMapsNavigator.getCurrentTimeAndDistance();
+    setState(() {
+      _remainingDistance = timeAndDistance.distance.toInt();
+      _remainingTime = timeAndDistance.time.toInt();
+      _delaySeverity = timeAndDistance.delaySeverity;
+    });
   }
 
   void _onTrafficUpdatedEvent() {
@@ -1431,7 +1440,7 @@ class _NavigationPageState extends ExamplePageState<NavigationPage> {
                   ),
                 if (_guidanceRunning)
                   ElevatedButton(
-                    onPressed: _validRoute ? _stopGuidedNavigation : null,
+                    onPressed: _validRoute ? _stopGuidance : null,
                     child: const Text('Stop Guidance'),
                   ),
                 if (_guidanceRunning &&

Additional Context

No response

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions