Skip to content

Commit 083fcc5

Browse files
jokerttucaio1985
andauthored
feat: deprecate continueToNextDestination method (#490)
* chore: reformat codebase with swift-format version 602.0.0 * feat: deprecate continueToNextDestination method --------- Co-authored-by: Caio Moreira <[email protected]>
1 parent 48dd3e4 commit 083fcc5

File tree

7 files changed

+193
-41
lines changed

7 files changed

+193
-41
lines changed

analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ analyzer:
2828
errors:
2929
# allow self-reference to deprecated members
3030
deprecated_member_use_from_same_package: ignore
31+
# allow deprecated member use in test files and examples
32+
deprecated_member_use: ignore
3133
exclude:
3234
# Ignore generated files
3335
- "**/*.g.dart"

example/android/app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ android {
5858
applicationId = "com.google.maps.flutter.navigation_example"
5959
// You can update the following values to match your application needs.
6060
// For more information, see: https://flutter.dev/to/review-gradle-config.
61-
minSdk = 23
61+
minSdk = flutter.minSdkVersion
6262
targetSdk = flutter.targetSdkVersion
6363
versionCode = flutter.versionCode
6464
versionName = flutter.versionName
@@ -123,4 +123,4 @@ secrets {
123123
ignoreList.add("sdk.*")
124124
// Ignore all keys matching the regexp "flutter.*"
125125
ignoreList.add("flutter.*")
126-
}
126+
}

example/integration_test/t01_initialization_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ void main() {
123123
}
124124

125125
try {
126+
// Note: Testing deprecated continueToNextDestination for proper exception
127+
// handling.
126128
await GoogleMapsNavigator.continueToNextDestination();
127129
fail('Expected SessionNotInitializedException.');
128130
} on Exception catch (e) {

example/integration_test/t03_navigation_test.dart

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ void main() {
3333

3434
final GoogleNavigationInspectorPlatform inspector =
3535
GoogleNavigationInspectorPlatform.instance!;
36+
final multipleDestinationsVariants = ValueVariant<String>(<String>{
37+
'continueToNextDestination',
38+
'setDestinations',
39+
});
3640

3741
/// Start location coordinates in Finland (Näkkäläntie).
3842
const double startLat = startLocationLat;
@@ -183,6 +187,7 @@ void main() {
183187
(PatrolIntegrationTester $) async {
184188
final Completer<void> navigationFinished = Completer<void>();
185189
int arrivalEventCount = 0;
190+
List<NavigationWaypoint> waypoints = <NavigationWaypoint>[];
186191

187192
/// Set up navigation view and controller.
188193
final GoogleNavigationViewController viewController =
@@ -208,7 +213,39 @@ void main() {
208213

209214
Future<void> onArrivalEvent(OnArrivalEvent msg) async {
210215
arrivalEventCount += 1;
211-
await GoogleMapsNavigator.continueToNextDestination();
216+
217+
if (multipleDestinationsVariants.currentValue ==
218+
'continueToNextDestination') {
219+
// Note: continueToNextDestination is deprecated.
220+
// This test still uses it to verify the deprecated API works correctly.
221+
// For new implementations, use setDestinations with updated waypoints instead.
222+
await GoogleMapsNavigator.continueToNextDestination();
223+
} else {
224+
// Find and remove the waypoint that matches the arrived waypoint
225+
int waypointIndex = -1;
226+
for (int i = 0; i < waypoints.length; i++) {
227+
final NavigationWaypoint waypoint = waypoints[i];
228+
if (waypoint.title == msg.waypoint.title) {
229+
waypointIndex = i;
230+
break;
231+
}
232+
}
233+
234+
if (waypointIndex >= 0) {
235+
waypoints.removeAt(waypointIndex);
236+
}
237+
238+
if (waypoints.isNotEmpty) {
239+
// Update destinations with remaining waypoints
240+
final Destinations updatedDestinations = Destinations(
241+
waypoints: waypoints,
242+
displayOptions: NavigationDisplayOptions(
243+
showDestinationMarkers: false,
244+
),
245+
);
246+
await GoogleMapsNavigator.setDestinations(updatedDestinations);
247+
}
248+
}
212249

213250
/// Finish executing the tests once 2 onArrival events come in.
214251
/// Test the guidance stops on last Arrival.
@@ -228,18 +265,21 @@ void main() {
228265
tolerance,
229266
);
230267

268+
/// Set up initial waypoints.
269+
waypoints = <NavigationWaypoint>[
270+
NavigationWaypoint.withLatLngTarget(
271+
title: 'Näkkäläntie 1st stop',
272+
target: const LatLng(latitude: midLat, longitude: midLon),
273+
),
274+
NavigationWaypoint.withLatLngTarget(
275+
title: 'Näkkäläntie 2nd stop',
276+
target: const LatLng(latitude: endLat, longitude: endLng),
277+
),
278+
];
279+
231280
/// Set Destination.
232281
final Destinations destinations = Destinations(
233-
waypoints: <NavigationWaypoint>[
234-
NavigationWaypoint.withLatLngTarget(
235-
title: 'Näkkäläntie 1st stop',
236-
target: const LatLng(latitude: midLat, longitude: midLon),
237-
),
238-
NavigationWaypoint.withLatLngTarget(
239-
title: 'Näkkäläntie 2nd stop',
240-
target: const LatLng(latitude: endLat, longitude: endLng),
241-
),
242-
],
282+
waypoints: waypoints,
243283
displayOptions: NavigationDisplayOptions(showDestinationMarkers: false),
244284
);
245285
final NavigationRouteStatus status =
@@ -293,6 +333,7 @@ void main() {
293333

294334
await GoogleMapsNavigator.cleanup();
295335
},
336+
variant: multipleDestinationsVariants,
296337
// TODO(jokerttu): Skipping Android as this fails on Android emulator on CI.
297338
skip: Platform.isAndroid,
298339
);

0 commit comments

Comments
 (0)