Is there an existing issue for this?
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
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:
- Go to "Navigation".
- Add a destination that provides multiple route alternatives.
- Start guidance.
- Stop guidance.
- 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
Is there an existing issue for this?
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:
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
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:
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
Additional Context
No response