hide clear button

This commit is contained in:
Valentin CZERYBA 2024-11-30 19:28:43 +01:00
parent 6b53dc170d
commit a4b747a273

View File

@ -419,15 +419,17 @@ class _MyHomePageState extends State<ListItemMenu> {
readOnly: true, readOnly: true,
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
suffixIcon: IconButton( suffixIcon: datePicker.text.isEmpty
icon: const Icon(Icons.clear), ? null
onPressed: () async { : IconButton(
setState(() { icon: const Icon(Icons.clear),
datePicker.text = ''; onPressed: () async {
}); setState(() {
fetchPostsByLocation(); datePicker.text = '';
}, });
), fetchPostsByLocation();
},
),
hintText: hintText), hintText: hintText),
onTap: () => onTap: () =>
onTapFunctionDatePicker(context: context, position: position)), onTapFunctionDatePicker(context: context, position: position)),
@ -444,24 +446,28 @@ class _MyHomePageState extends State<ListItemMenu> {
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'Search by geographical zone', labelText: 'Search by geographical zone',
border: OutlineInputBorder(), border: OutlineInputBorder(),
suffixIcon: IconButton( suffixIcon: inputGeo.text.isEmpty
icon: const Icon(Icons.clear), ? null
onPressed: () async { : IconButton(
SharedPreferences prefs = icon: const Icon(Icons.clear),
await SharedPreferences.getInstance(); onPressed: () async {
prefs.remove("city_lat"); SharedPreferences prefs =
prefs.remove("city_long"); await SharedPreferences.getInstance();
setState(() { prefs.remove("city_lat");
inputGeo.clear(); // Clear the text field prefs.remove("city_long");
geographicalZone = ''; // Reset the geographical zone state setState(() {
suggestions.clear(); inputGeo.clear(); // Clear the text field
showArrow = true; geographicalZone =
showInputSearch = true; // Optionally clear suggestions ''; // Reset the geographical zone state
/// Clear the filtered posts suggestions.clear();
}); showArrow = true;
fetchPostsByLocation(); showInputSearch =
}, true; // Optionally clear suggestions
), /// Clear the filtered posts
});
fetchPostsByLocation();
},
),
), ),
onChanged: (value) async { onChanged: (value) async {
if (value.isNotEmpty) { if (value.isNotEmpty) {
@ -537,19 +543,21 @@ class _MyHomePageState extends State<ListItemMenu> {
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'Search by item', labelText: 'Search by item',
border: OutlineInputBorder(), border: OutlineInputBorder(),
suffixIcon: IconButton( suffixIcon: inputItem.text.isEmpty
icon: const Icon(Icons.clear), ? null
onPressed: () { : IconButton(
setState(() { icon: const Icon(Icons.clear),
inputItem.clear(); onPressed: () {
itemName = ''; // Reset the geographical zone state setState(() {
suggestionsItem.clear(); inputItem.clear();
showDateFields = true; itemName = ''; // Reset the geographical zone state
showArrow = true; suggestionsItem.clear();
}); showDateFields = true;
fetchPostsByLocation(); showArrow = true;
}, });
), fetchPostsByLocation();
},
),
), ),
onChanged: (value) { onChanged: (value) {
if (value.isNotEmpty) { if (value.isNotEmpty) {