diff --git a/lib/src/config/app_config.dart b/lib/src/config/app_config.dart index e3d54c2..95ff9a3 100644 --- a/lib/src/config/app_config.dart +++ b/lib/src/config/app_config.dart @@ -1,7 +1,7 @@ class AppConfig { static const apiUrl = String.fromEnvironment( 'VERDE_API_URL', - defaultValue: 'http://192.168.254.173:8000/api/v1', + defaultValue: 'http://192.168.254.171:8000/api/v1', ); static const appName = 'Verde Scanner'; } diff --git a/lib/src/data/dop/dop_repository.dart b/lib/src/data/dop/dop_repository.dart index 3728458..dd7490a 100644 --- a/lib/src/data/dop/dop_repository.dart +++ b/lib/src/data/dop/dop_repository.dart @@ -43,7 +43,7 @@ class DopRepository { /// Returns DOPs near the given position. Backend endpoint is public /// but tenancy still applies via the X-Tenant-Code header. - Future> nearby(double lat, double lng, {double radiusKm = 50}) async { + Future> nearby(double lat, double lng, {double radiusKm = 25000}) async { final res = await _dio.get('/drop-off-points/nearby', queryParameters: { 'lat': lat, 'lng': lng, 'radius_km': radiusKm, 'limit': 50, }); @@ -63,8 +63,16 @@ final dopRepositoryProvider = Provider((ref) { /// Reads the current GPS once, then asks the backend for nearby DOPs. /// Re-run by invalidating the provider. final nearbyDopsProvider = FutureProvider>((ref) async { - final pos = await Geolocator.getCurrentPosition( - locationSettings: const LocationSettings(accuracy: LocationAccuracy.medium), - ); - return ref.watch(dopRepositoryProvider).nearby(pos.latitude, pos.longitude); + double lat = 14.6539; + double lng = 121.0685; + try { + final pos = await Geolocator.getCurrentPosition( + locationSettings: const LocationSettings(accuracy: LocationAccuracy.medium), + ).timeout(const Duration(seconds: 4)); + lat = pos.latitude; + lng = pos.longitude; + } catch (_) { + // Graceful fallback when GPS times out or throws an error on emulators + } + return ref.watch(dopRepositoryProvider).nearby(lat, lng); });