search_widget
1.0.0
Este paquete Flutter proporciona un widget de búsqueda para seleccionar una opción de una lista de datos. Proporciona filtrado de elementos según el texto de búsqueda.
En la sección dependencies:
de tu pubspec.yaml
, agrega la siguiente línea:
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);
},
)