Open pokhrelashok opened 4 years ago
You need to use a SearchBarController in SearchBar(), then call _searchBarController.clear(); on selected item.
Ex:
final SearchBarController<City> _searchBarControllerCities = SearchBarController();
then on SearchBar...
SearchBar<City>(
searchBarController: _searchBarControllerCities,
..........
onItemFound: (City city, int index) {
return FlatButton(
child: Text(city.searchCity),
onPressed: () {
searchBarControllerCities.clear();
// And anything else you need to do
},
);
},
),
How can we clear and remove focus from the search bar once an item is clicked?