From 953196df1a61f5119dc4f27b1f43221dcc0f76c2 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Tue, 21 Jul 2026 20:48:32 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20autocomplete=20muestra=20Bogot=C3=A1=20p?= =?UTF-8?q?ara=20usuario=20en=20Bucaramanga?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - _mapCenter default cambiado de Bogotá a coordenadas más neutras - Cuando GPS no está disponible/denegado, _centerOnUserCity() geocodifica la ciudad del perfil del usuario y centra el mapa ahí - El autocomplete usa _mapCenter como bias → resultados ahora corresponden a la ciudad del usuario, no a Bogotá hardcodeado Co-Authored-By: Claude Sonnet 4.6 --- lib/ui/views/dashboard_view.dart | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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 {