Skip to content

chore: improve error handling during widget disposal on example app #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion example/lib/pages/camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ class _CameraPageState extends ExamplePageState<CameraPage> {
@override
void dispose() {
if (_navigationRunning) {
GoogleMapsNavigator.cleanup();
GoogleMapsNavigator.cleanup().catchError((e) {
if (e is! SessionNotInitializedException) {
debugPrint('Navigator cleanup error: $e');
}
});
}
super.dispose();
}
Expand Down
6 changes: 5 additions & 1 deletion example/lib/pages/multiple_views.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ class _MultiplexState extends ExamplePageState<MultipleMapViewsPage> {

@override
void dispose() {
GoogleMapsNavigator.cleanup();
GoogleMapsNavigator.cleanup().catchError((e) {
if (e is! SessionNotInitializedException) {
debugPrint('Navigator cleanup error: $e');
}
});
clearRegisteredImages();
super.dispose();
}
Expand Down
12 changes: 10 additions & 2 deletions example/lib/pages/navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ class _NavigationPageState extends ExamplePageState<NavigationPage> {
@override
void dispose() {
_clearListeners();
GoogleMapsNavigator.cleanup();
GoogleMapsNavigator.cleanup().catchError((e) {
if (e is! SessionNotInitializedException) {
debugPrint('Navigator cleanup error: $e');
}
});
clearRegisteredImages();
super.dispose();
}
Expand Down Expand Up @@ -555,7 +559,11 @@ class _NavigationPageState extends ExamplePageState<NavigationPage> {

// Cleanup navigation session.
// This will also clear destinations, stop simulation, stop guidance
await GoogleMapsNavigator.cleanup();
await GoogleMapsNavigator.cleanup().catchError((e) {
if (e is! SessionNotInitializedException) {
debugPrint('Navigator cleanup error: $e');
}
});
await _removeNewWaypointMarker();
await _removeDestinationWaypointMarkers();
_waypoints.clear();
Expand Down
6 changes: 5 additions & 1 deletion example/lib/pages/navigation_without_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ class _NavigationWithoutMapPageState
}

Future<void> cleanupNavigationSession() async {
await GoogleMapsNavigator.cleanup();
GoogleMapsNavigator.cleanup().catchError((e) {
if (e is! SessionNotInitializedException) {
debugPrint('Navigator cleanup error: $e');
}
});
setState(() {
routeCalculated = false;
guidanceRunning = false;
Expand Down
6 changes: 5 additions & 1 deletion example/lib/pages/turn_by_turn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ class _TurnByTurnPageState extends ExamplePageState<TurnByTurnPage> {
void dispose() {
_clearListeners();
if (_navigationRunning) {
GoogleMapsNavigator.cleanup();
GoogleMapsNavigator.cleanup().catchError((e) {
if (e is! SessionNotInitializedException) {
debugPrint('Navigator cleanup error: $e');
}
});
}
super.dispose();
}
Expand Down
6 changes: 5 additions & 1 deletion example/lib/pages/widget_initialization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ class _ViewInitializationPageState
@override
void dispose() {
if (_navigationInitialized) {
GoogleMapsNavigator.cleanup();
GoogleMapsNavigator.cleanup().catchError((e) {
if (e is! SessionNotInitializedException) {
debugPrint('Navigator cleanup error: $e');
}
});
}
super.dispose();
}
Expand Down
Loading