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