Skip to content

Commit ba2cfa7

Browse files
committed
fix: onNewNavigationSession event firing for continueToNextDestination
1 parent 60c02af commit ba2cfa7

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

example/integration_test/t03_navigation_test.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ void main() {
197197
Future<void> onArrivalEvent(OnArrivalEvent msg) async {
198198
arrivalEventCount += 1;
199199
if (arrivalEventCount < 2) {
200+
// Reset the completer to test that new session event fires again
201+
newSessionFired = Completer<void>();
202+
200203
if (multipleDestinationsVariants.currentValue ==
201204
'continueToNextDestination') {
202205
// Note: continueToNextDestination is deprecated.
@@ -210,9 +213,6 @@ void main() {
210213
SimulationOptions(speedMultiplier: 5),
211214
);
212215
} else {
213-
// Reset the completer to test that new session event fires again
214-
newSessionFired = Completer<void>();
215-
216216
// Find and remove the waypoint that matches the arrived waypoint
217217
int waypointIndex = -1;
218218
for (int i = 0; i < waypoints.length; i++) {
@@ -237,22 +237,22 @@ void main() {
237237
);
238238
await GoogleMapsNavigator.setDestinations(updatedDestinations);
239239

240-
// Wait for new session event after updating destinations
241-
await newSessionFired.future.timeout(
242-
const Duration(seconds: 10),
243-
onTimeout:
244-
() =>
245-
throw TimeoutException(
246-
'New navigation session event was not fired after updating destinations',
247-
),
248-
);
249-
250240
await GoogleMapsNavigator.simulator
251241
.simulateLocationsAlongExistingRouteWithOptions(
252242
SimulationOptions(speedMultiplier: 5),
253243
);
254244
}
255245
}
246+
247+
// Wait for new session event after updating destinations
248+
await newSessionFired.future.timeout(
249+
const Duration(seconds: 10),
250+
onTimeout:
251+
() =>
252+
throw TimeoutException(
253+
'New navigation session event was not fired after updating destinations',
254+
),
255+
);
256256
} else {
257257
$.log('Got second arrival event, stopping guidance');
258258
// Stop guidance after the last destination

ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationSessionManager.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ class GoogleMapsNavigationSessionManager: NSObject {
306306
}
307307

308308
func continueToNextDestination() throws -> NavigationWaypointDto? {
309+
// Reset session detection state to allow onNewNavigationSession to fire again
310+
// This mimics Android's behavior where the event fires when continuing to next destination
311+
_isNewNavigationSessionDetected = false
312+
309313
guard let nextWaypoint = try getNavigator().continueToNextDestination() else { return nil }
310314
return Convert.convertNavigationWayPoint(nextWaypoint)
311315
}

0 commit comments

Comments
 (0)