diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart index 1391715..3614d9c 100644 --- a/covas_mobile/lib/pages/ListItemMenu.dart +++ b/covas_mobile/lib/pages/ListItemMenu.dart @@ -419,15 +419,17 @@ class _MyHomePageState extends State { readOnly: true, decoration: InputDecoration( border: OutlineInputBorder(), - suffixIcon: IconButton( - icon: const Icon(Icons.clear), - onPressed: () async { - setState(() { - datePicker.text = ''; - }); - fetchPostsByLocation(); - }, - ), + suffixIcon: datePicker.text.isEmpty + ? null + : IconButton( + icon: const Icon(Icons.clear), + onPressed: () async { + setState(() { + datePicker.text = ''; + }); + fetchPostsByLocation(); + }, + ), hintText: hintText), onTap: () => onTapFunctionDatePicker(context: context, position: position)), @@ -444,24 +446,28 @@ class _MyHomePageState extends State { decoration: InputDecoration( labelText: 'Search by geographical zone', border: OutlineInputBorder(), - suffixIcon: IconButton( - icon: const Icon(Icons.clear), - onPressed: () async { - 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(); - showArrow = true; - showInputSearch = true; // Optionally clear suggestions - /// Clear the filtered posts - }); - fetchPostsByLocation(); - }, - ), + suffixIcon: inputGeo.text.isEmpty + ? null + : IconButton( + icon: const Icon(Icons.clear), + onPressed: () async { + 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(); + showArrow = true; + showInputSearch = + true; // Optionally clear suggestions + /// Clear the filtered posts + }); + fetchPostsByLocation(); + }, + ), ), onChanged: (value) async { if (value.isNotEmpty) { @@ -537,19 +543,21 @@ class _MyHomePageState extends State { decoration: InputDecoration( labelText: 'Search by item', border: OutlineInputBorder(), - suffixIcon: IconButton( - icon: const Icon(Icons.clear), - onPressed: () { - setState(() { - inputItem.clear(); - itemName = ''; // Reset the geographical zone state - suggestionsItem.clear(); - showDateFields = true; - showArrow = true; - }); - fetchPostsByLocation(); - }, - ), + suffixIcon: inputItem.text.isEmpty + ? null + : IconButton( + icon: const Icon(Icons.clear), + onPressed: () { + setState(() { + inputItem.clear(); + itemName = ''; // Reset the geographical zone state + suggestionsItem.clear(); + showDateFields = true; + showArrow = true; + }); + fetchPostsByLocation(); + }, + ), ), onChanged: (value) { if (value.isNotEmpty) {