From 4ec4b79f2c7dcb7bc4df13876ba55998e13321cf Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Thu, 28 Nov 2024 22:26:12 +0100 Subject: [PATCH] fix input geo search --- covas_mobile/lib/pages/ListItemMenu.dart | 28 +++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart index 2dcdf37..0e17203 100644 --- a/covas_mobile/lib/pages/ListItemMenu.dart +++ b/covas_mobile/lib/pages/ListItemMenu.dart @@ -420,18 +420,34 @@ class _MyHomePageState extends State { setState(() { inputGeo.clear(); // Clear the text field geographicalZone = ''; // Reset the geographical zone state - suggestions.clear(); // Optionally clear suggestions + suggestions.clear(); + showArrow = true; // Optionally clear suggestions /// Clear the filtered posts }); fetchPostsByLocation(); }, ), ), - onChanged: (value) { - setState(() { - geographicalZone = value; - searchSuggestions(value); - }); + onChanged: (value) async { + if (value.isNotEmpty) { + setState(() { + geographicalZone = value; + searchSuggestions(value); + }); + } else { + SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.remove("city_lat"); + prefs.remove("city_long"); + setState(() { + inputGeo.clear(); // Clear the text field + geographicalZone = ''; // Reset the geographical zone state + suggestions.clear(); // Optionally clear suggestions + showArrow = true; + + /// Clear the filted posts + }); + fetchPostsByLocation(); + } }, ), if (suggestions.isNotEmpty)