diff --git a/lib/ui/views/dashboard_view.dart b/lib/ui/views/dashboard_view.dart index af53296..11b70f4 100644 --- a/lib/ui/views/dashboard_view.dart +++ b/lib/ui/views/dashboard_view.dart @@ -37,7 +37,7 @@ class _DashboardViewState extends State { // Map GoogleMapController? _mapController; - LatLng _mapCenter = const LatLng(4.6097, -74.0817); + LatLng _mapCenter = const LatLng(6.2442, -75.5812); // Medellín — centro geográfico de Colombia como fallback neutro bool _mapsReady = false; bool _mapsLoading = true; bool _geocoding = false; @@ -88,14 +88,14 @@ class _DashboardViewState extends State { Future _detectLocation() async { try { bool serviceEnabled = await Geolocator.isLocationServiceEnabled(); - if (!serviceEnabled) return; + if (!serviceEnabled) { await _centerOnUserCity(); return; } LocationPermission permission = await Geolocator.checkPermission(); if (permission == LocationPermission.denied) { permission = await Geolocator.requestPermission(); - if (permission == LocationPermission.denied) return; + if (permission == LocationPermission.denied) { await _centerOnUserCity(); return; } } - if (permission == LocationPermission.deniedForever) return; + if (permission == LocationPermission.deniedForever) { await _centerOnUserCity(); return; } final pos = await Geolocator.getCurrentPosition( locationSettings: const LocationSettings( @@ -108,7 +108,15 @@ class _DashboardViewState extends State { if (mounted) setState(() => _mapCenter = latlng); _mapController?.animateCamera(CameraUpdate.newLatLngZoom(latlng, 16)); _reverseGeocode(latlng); - } catch (_) {} + } catch (_) { + await _centerOnUserCity(); + } + } + + Future _centerOnUserCity() async { + final city = user?.city; + if (city == null || city.isEmpty) return; + await _geocodeAndMoveMap(city); } Future _reverseGeocode(LatLng pos) async {