diff --git a/lib/ui/views/dashboard_view.dart b/lib/ui/views/dashboard_view.dart index 59f1e3e..f747b88 100644 --- a/lib/ui/views/dashboard_view.dart +++ b/lib/ui/views/dashboard_view.dart @@ -165,11 +165,14 @@ class _DashboardViewState extends State { } _debounce = Timer(const Duration(milliseconds: 450), () async { final uri = Uri.https('admin.prosapp.co', '/autocomplete', { - 'input': value.replaceAll(' ', '_'), + 'input': value, + 'location': '${_mapCenter.latitude},${_mapCenter.longitude}', }); final response = await NetworkUtility.fetchUrl(uri); if (response != null && mounted) { - setState(() => _suggestions = jsonDecode(response)['results'] ?? []); + final decoded = jsonDecode(response); + final results = decoded['results'] ?? decoded['predictions'] ?? []; + setState(() => _suggestions = results is List ? results : []); } }); } @@ -388,7 +391,8 @@ class _DashboardViewState extends State { ), child: Column( children: _suggestions.take(5).toList().asMap().entries.map((e) { - final addr = e.value['formatted_address'] as String? ?? ''; + final item = e.value as Map; + final addr = (item['formatted_address'] ?? item['description'] ?? item['name'] ?? '').toString(); final isLast = e.key == (_suggestions.length - 1).clamp(0, 4); return Column( children: [