@@ -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
0 commit comments