Skip to content

Commit 36849db

Browse files
committed
chore: improve error handling during widget disposal on example app
1 parent a137af4 commit 36849db

File tree

6 files changed

+35
-7
lines changed

6 files changed

+35
-7
lines changed

example/lib/pages/camera.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ class _CameraPageState extends ExamplePageState<CameraPage> {
119119
@override
120120
void dispose() {
121121
if (_navigationRunning) {
122-
GoogleMapsNavigator.cleanup();
122+
GoogleMapsNavigator.cleanup().catchError((e) {
123+
if (e is! SessionNotInitializedException) {
124+
debugPrint('Navigator cleanup error: $e');
125+
}
126+
});
123127
}
124128
super.dispose();
125129
}

example/lib/pages/multiple_views.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ class _MultiplexState extends ExamplePageState<MultipleMapViewsPage> {
8282

8383
@override
8484
void dispose() {
85-
GoogleMapsNavigator.cleanup();
85+
GoogleMapsNavigator.cleanup().catchError((e) {
86+
if (e is! SessionNotInitializedException) {
87+
debugPrint('Navigator cleanup error: $e');
88+
}
89+
});
8690
clearRegisteredImages();
8791
super.dispose();
8892
}

example/lib/pages/navigation.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ class _NavigationPageState extends ExamplePageState<NavigationPage> {
170170
@override
171171
void dispose() {
172172
_clearListeners();
173-
GoogleMapsNavigator.cleanup();
173+
GoogleMapsNavigator.cleanup().catchError((e) {
174+
if (e is! SessionNotInitializedException) {
175+
debugPrint('Navigator cleanup error: $e');
176+
}
177+
});
174178
clearRegisteredImages();
175179
super.dispose();
176180
}
@@ -623,7 +627,11 @@ class _NavigationPageState extends ExamplePageState<NavigationPage> {
623627

624628
// Cleanup navigation session.
625629
// This will also clear destinations, stop simulation, stop guidance
626-
await GoogleMapsNavigator.cleanup();
630+
await GoogleMapsNavigator.cleanup().catchError((e) {
631+
if (e is! SessionNotInitializedException) {
632+
debugPrint('Navigator cleanup error: $e');
633+
}
634+
});
627635
await _removeNewWaypointMarker();
628636
await _removeDestinationWaypointMarkers();
629637
_waypoints.clear();

example/lib/pages/navigation_without_map.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ class _NavigationWithoutMapPageState
110110
}
111111

112112
Future<void> cleanupNavigationSession() async {
113-
await GoogleMapsNavigator.cleanup();
113+
GoogleMapsNavigator.cleanup().catchError((e) {
114+
if (e is! SessionNotInitializedException) {
115+
debugPrint('Navigator cleanup error: $e');
116+
}
117+
});
114118
setState(() {
115119
routeCalculated = false;
116120
guidanceRunning = false;

example/lib/pages/turn_by_turn.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ class _TurnByTurnPageState extends ExamplePageState<TurnByTurnPage> {
130130
void dispose() {
131131
_clearListeners();
132132
if (_navigationRunning) {
133-
GoogleMapsNavigator.cleanup();
133+
GoogleMapsNavigator.cleanup().catchError((e) {
134+
if (e is! SessionNotInitializedException) {
135+
debugPrint('Navigator cleanup error: $e');
136+
}
137+
});
134138
}
135139
super.dispose();
136140
}

example/lib/pages/widget_initialization.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ class _ViewInitializationPageState
7070
@override
7171
void dispose() {
7272
if (_navigationInitialized) {
73-
GoogleMapsNavigator.cleanup();
73+
GoogleMapsNavigator.cleanup().catchError((e) {
74+
if (e is! SessionNotInitializedException) {
75+
debugPrint('Navigator cleanup error: $e');
76+
}
77+
});
7478
}
7579
super.dispose();
7680
}

0 commit comments

Comments
 (0)