Migrate to 3.1.14
This guide outlines the breaking changes introduced in SDK version 3.1.14. Required updates may vary depending on your use case.
Additionally, new features and bugfixes have been introduced and are not documented here. For a comprehensive list of changes, please refer to the changelog.
This release changes the signature of the onRouteUpdated navigation callback. Only projects that pass this callback to startNavigation or startSimulation need an update.
The onRouteUpdated callback of the NavigationService class now receives a details parameter
The onRouteUpdated callback of the startNavigation and startSimulation methods now takes a second parameter, a Set<RouteUpdateDetails> describing why the route was updated. A callback declared with the old single-parameter signature no longer compiles.
Before:
void onRouteUpdated(Route route) {
// Display the updated route
}
NavigationService.startNavigation(
route,
onRouteUpdated: onRouteUpdated,
);
After:
void onRouteUpdated(Route route, Set<RouteUpdateDetails> details) {
// Display the updated route
if (details.contains(RouteUpdateDetails.reverse)) {
// The recalculated route heads in the opposite travel direction
}
}
NavigationService.startNavigation(
route,
onRouteUpdated: onRouteUpdated,
);
The details set can hold the following values:
| Value | Meaning |
|---|---|
recalculated | The route was recalculated, for example after leaving the route or after a roadblock was added. |
reverse | The recalculated route heads in the opposite travel direction. Always reported together with recalculated. |
trimTraveled | An intermediate destination was reached or skipped and the traveled part of the route was trimmed. |
calculated | The first route calculation finished. Not reported by startNavigation and startSimulation, which start from an already calculated route. |
If you do not need the details, accept and ignore the parameter: (route, _) { ... }.