11import 'package:flutter/material.dart' ;
2- import 'package:flutter_map/flutter_map.dart' ;
32import 'package:flutter_map_animations/flutter_map_animations.dart' ;
43import 'package:flutter_svg/flutter_svg.dart' ;
5- import 'package:latlong2/latlong.dart' ;
64import 'package:provider/provider.dart' ;
75
86import '../app_state.dart' ;
97import '../dev_config.dart' ;
108import '../widgets/map_view.dart' ;
119import '../services/localization_service.dart' ;
1210
13- import '../widgets/add_node_sheet.dart' ;
14- import '../widgets/edit_node_sheet.dart' ;
1511import '../widgets/node_tag_sheet.dart' ;
1612import '../widgets/download_area_dialog.dart' ;
1713import '../widgets/measured_sheet.dart' ;
18- import '../widgets/navigation_sheet.dart' ;
1914import '../widgets/search_bar.dart' ;
2015import '../widgets/suspected_location_sheet.dart' ;
2116import '../widgets/welcome_dialog.dart' ;
@@ -190,6 +185,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
190185
191186 // Run any needed migrations first
192187 final versionsNeedingMigration = await ChangelogService ().getVersionsNeedingMigration ();
188+ if (! mounted) return ;
193189 for (final version in versionsNeedingMigration) {
194190 await ChangelogService ().runMigration (version, appState, context);
195191 }
@@ -214,6 +210,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
214210
215211 case PopupType .changelog:
216212 final changelogContent = await ChangelogService ().getChangelogContentForDisplay ();
213+ if (! mounted) return ;
217214 if (changelogContent != null ) {
218215 await showDialog (
219216 context: context,
@@ -252,35 +249,6 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
252249 );
253250 }
254251
255- void _zoomAndCenterForRoute (bool followMeEnabled, LatLng ? userLocation, LatLng ? routeStart) {
256- try {
257- LatLng centerLocation;
258-
259- if (followMeEnabled && userLocation != null ) {
260- // Center on user if follow-me is enabled
261- centerLocation = userLocation;
262- debugPrint ('[HomeScreen] Centering on user location for route start' );
263- } else if (routeStart != null ) {
264- // Center on start pin if user is far away or no GPS
265- centerLocation = routeStart;
266- debugPrint ('[HomeScreen] Centering on route start pin' );
267- } else {
268- debugPrint ('[HomeScreen] No valid location to center on' );
269- return ;
270- }
271-
272- // Animate to zoom 14 and center location
273- _mapController.animateTo (
274- dest: centerLocation,
275- zoom: 14.0 ,
276- duration: const Duration (milliseconds: 800 ),
277- curve: Curves .easeInOut,
278- );
279- } catch (e) {
280- debugPrint ('[HomeScreen] Could not zoom/center for route: $e ' );
281- }
282- }
283-
284252 void _onResumeRoute () {
285253 _navigationCoordinator.resumeRoute (
286254 context: context,
@@ -402,9 +370,11 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
402370 );
403371
404372 // Reset height and clear selection when sheet is dismissed
373+ final appState = context.read <AppState >();
405374 controller.closed.then ((_) {
375+ if (! mounted) return ;
406376 _sheetCoordinator.resetTagSheetHeight (() => setState (() {}));
407- context. read < AppState >() .clearSuspectedLocationSelection ();
377+ appState .clearSuspectedLocationSelection ();
408378 });
409379 }
410380
@@ -578,7 +548,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
578548 borderRadius: BorderRadius .circular (16 ),
579549 boxShadow: [
580550 BoxShadow (
581- color: Theme .of (context).shadowColor.withOpacity ( 0.3 ),
551+ color: Theme .of (context).shadowColor.withValues (alpha : 0.3 ),
582552 blurRadius: 10 ,
583553 offset: Offset (0 , - 2 ),
584554 )
0 commit comments