search_widget
1.0.0
Este pacote Flutter fornece um widget de pesquisa para selecionar uma opção em uma lista de dados. Fornece filtragem de itens com base no texto de pesquisa.
Na seção dependencies:
do seu pubspec.yaml
, adicione a seguinte linha:
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);
},
)