search_widget
1.0.0
此 Flutter 套件提供了一個搜尋小工具,用於從資料清單中選擇選項。提供基於搜尋文字的項目過濾。
在pubspec.yaml
的dependencies:
部分中,加入以下行:
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);
},
)