Skip to content

Commit dcf0228

Browse files
committed
fix: onNewNavigationSession event firing for continueToNextDestination
1 parent 7b8a08b commit dcf0228

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
@@ -189,6 +189,9 @@ void main() {
189189
Future<void> onArrivalEvent(OnArrivalEvent msg) async {
190190
arrivalEventCount += 1;
191191
if (arrivalEventCount < 2) {
192+
// Reset the completer to test that new session event fires again
193+
newSessionFired = Completer<void>();
194+
192195
if (multipleDestinationsVariants.currentValue ==
193196
'continueToNextDestination') {
194197
// Note: continueToNextDestination is deprecated.
@@ -202,9 +205,6 @@ void main() {
202205
SimulationOptions(speedMultiplier: 5),
203206
);
204207
} else {
205-
// Reset the completer to test that new session event fires again
206-
newSessionFired = Completer<void>();
207-
208208
// Find and remove the waypoint that matches the arrived waypoint
209209
int waypointIndex = -1;
210210
for (int i = 0; i < waypoints.length; i++) {
@@ -229,22 +229,22 @@ void main() {
229229
);
230230
await GoogleMapsNavigator.setDestinations(updatedDestinations);
231231

232-
// Wait for new session event after updating destinations
233-
await newSessionFired.future.timeout(
234-
const Duration(seconds: 10),
235-
onTimeout:
236-
() =>
237-
throw TimeoutException(
238-
'New navigation session event was not fired after updating destinations',
239-
),
240-
);
241-
242232
await GoogleMapsNavigator.simulator
243233
.simulateLocationsAlongExistingRouteWithOptions(
244234
SimulationOptions(speedMultiplier: 5),
245235
);
246236
}
247237
}
238+
239+
// Wait for new session event after updating destinations
240+
await newSessionFired.future.timeout(
241+
const Duration(seconds: 10),
242+
onTimeout:
243+
() =>
244+
throw TimeoutException(
245+
'New navigation session event was not fired after updating destinations',
246+
),
247+
);
248248
} else {
249249
$.log('Got second arrival event, stopping guidance');
250250
// 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)