search_widget
1.0.0
Этот пакет Flutter предоставляет виджет поиска для выбора параметра из списка данных. Обеспечивает фильтрацию элементов на основе искомого текста.
В разделе dependencies:
вашего pubspec.yaml
добавьте следующую строку:
dependencies :
search_widget : <latest version>
import 'package:search_widget/search_widget.dart' ;
onItemSelected : (item) {
//Do whatever you would like
setState (() {
_selectedItem = item;
});
},
popupListItemBuilder : ( LeaderBoard item) {
return PopupListItem (item);
}
queryBuilder : ( String query, List < LeaderBoard > list) {
return list. where (( LeaderBoard item) => item.username. toLowerCase (). contains (query. toLowerCase ())). toList ();
}
selectedItemBuilder : ( LeaderBoard selectedItem, deleteSelectedItem) {
return SelectedItem (selectedItem,deleteSelectedItem);
}
textFieldBuilder : ( TextEditingController controller, FocusNode focusNode) {
return TextField (
controller : controller,
focusNode : focusNode,
//... Other customizations here
);
},
SearchWidget < LeaderBoard >(
dataList : list,
hideSearchBoxWhenItemSelected : false ,
listContainerHeight : MediaQuery . of (context).size.height / 4 ,
queryBuilder : ( String query, List < LeaderBoard > list) {
return list. where (( LeaderBoard item) => item.username. toLowerCase (). contains (query. toLowerCase ())). toList ();
},
popupListItemBuilder : ( LeaderBoard item) {
return PopupListItemWidget (item);
},
selectedItemBuilder : ( LeaderBoard selectedItem, VoidCallback deleteSelectedItem) {
return SelectedItemWidget (selectedItem, deleteSelectedItem);
},
// widget customization
noItemsFoundWidget : NoItemsFound (),
textFieldBuilder : ( TextEditingController controller, FocusNode focusNode) {
return MyTextField (controller, focusNode);
},
)