googlemaps / googlemaps/flutter-navigation-sdk

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

Open
#699 5 comments 0 reactions 1 assignee Claimed by @jokerttu View on GitHub
native sdk issue priority: p2 type: bug
Dominant language
Dart
Stars
75
Forks
54
Avg merge
4d 2h
Merged PRs (30d)
5

Description

### Is there an existing issue for this?

- [x] 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

- [x] 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 {
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 _waypoints = [];
@@ -509,7 +509,7 @@ class _NavigationPageState extends ExamplePageState {
});
}

- void _onRouteChangedEvent() {
+ void _onRouteChangedEvent() async {
if (!mounted) {
return;
}
@@ -520,9 +520,18 @@ class _NavigationPageState extends ExamplePageState {
// 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 {
),
if (_guidanceRunning)
ElevatedButton(
- onPressed: _validRoute ? _stopGuidedNavigation : null,
+ onPressed: _validRoute ? _stopGuidance : null,
child: const Text('Stop Guidance'),
),
if (_guidanceRunning &&

```

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.