searchable_textfeild 0.1.9
searchable_textfeild: ^0.1.9 copied to clipboard
A simple textfeild which can be used to search the data in the list or can be used as simple dropdown widget
Searchable TextField #
A highly customizable Flutter widget that combines TextField functionality with dropdown search capabilities, multi-select support, and API integration.
Features #
- Standard TextField functionality with full customization
- Dropdown with search functionality
- API-based search support with pagination
- Multi-select support with checkbox customization
- Appendable items with custom tap handling
- Form validation support
- Customizable loading indicators
- Rich text input customization
- Keyboard handling and input formatting
Support My Work #
If you find this package useful, consider supporting me with a coffee. Your support helps me maintain and improve this package! ☕️
Installation #
dependencies:
searchable_textfield: ^latest_version
Basic Usage #
SearchableTextField(
controller: TextEditingController(),
enabled: true,
isDropdown: true,
items: [
DropdownMenuItems(lable: "Item 1", value: "1"),
DropdownMenuItems(lable: "Item 2", value: "2"),
],
onChanged: (value, label) {
print("Selected value: $value, label: $label");
},
)
Multi-Select Example #
SearchableTextField(
controller: TextEditingController(),
isDropdown: true,
isMultiSelect: true,
checkboxActiveColor: Colors.blue,
checkboxCheckColor: Colors.white,
selectedItemStyle: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.bold,
),
maxSelections: 3,
selectionSeparator: ' | ',
items: [
DropdownMenuItems(lable: "Item 1", value: "1"),
DropdownMenuItems(lable: "Item 2", value: "2"),
],
)
API Integration #
SearchableTextField(
controller: TextEditingController(),
isDropdown: true,
getItems: ({page, filter, limit}) async {
// Your API call here
return yourApiResponse.map((item) =>
DropdownMenuItems(lable: item.name, value: item.id)
).toList();
},
loadingWidget: YourCustomLoadingWidget(),
)
Appendable Items Example #
SearchableTextField(
controller: TextEditingController(),
isDropdown: true,
items: [
DropdownMenuItems(lable: "Item 1", value: "1"),
DropdownMenuItems(lable: "Item 2", value: "2"),
],
appendableItems: [
ListTile(
leading: Icon(Icons.add),
title: Text("Add New Item"),
),
ListTile(
leading: Icon(Icons.refresh),
title: Text("Refresh List"),
),
],
onAppendableItemTap: (index) {
// Handle tap on appendable items
switch(index) {
case 0: // Add New Item
print("Add new item tapped");
break;
case 1: // Refresh List
print("Refresh list tapped");
break;
}
},
)
Appendable Items Options #
appendableItems: List of widgets to show below the dropdownonAppendableItemTap: Callback that provides the index of tapped item- Supports any widget as appendable item
- Auto-closes dropdown after tap (configurable)
- Inherits dropdown styling (background, elevation, etc.)
Customization Options #
Core Properties #
controller: TextEditingController for managing inputenabled: Enable/disable the fieldisDropdown: Enable dropdown functionalityisMultiSelect: Enable multi-select modevalidator: Form validation functiononChanged: Callback for value changes (value, label)
Visual Customization #
style: Text style for inputdropdownItemStyle: Style for dropdown itemsselectedItemStyle: Style for selected itemsdropdownDecoration: Custom dropdown BoxDecorationdropdownBackgroundColor: Background colordropdownItemPadding: Padding for itemsdropdownElevation: Shadow elevation
Multi-select Options #
maxSelections: Limit number of selectionsselectionSeparator: Separator for selected itemscheckboxActiveColor: Color when checkedcheckboxCheckColor: Checkbox tick colorselectionIndicator: Custom indicator widget
Input Handling #
keyboardType: Type of keyboard to displayinputFormatter: Input formatting rulestextAlign: Text alignmenttextAlignVertical: Vertical alignmentreadOnly: Prevent editingobscureText: Hide input textmaxLines/minLines: Line constraintsmaxLength: Character limit
Advanced Features #
autofillHints: Autofill suggestionsscrollController: Custom scroll controlscrollPhysics: Scroll behaviorenableIMEPersonalizedLearning: IME learningcursorColor/cursorWidth/cursorRadius: Cursor customizationsmartDashesType/smartQuotesType: Smart text formatting
Contribution #
Contributions are welcome! Please feel free to submit pull requests.
Connect with me #
- GitHub: Your GitHub Profile
- LinkedIn: Your LinkedIn Profile
License #
This project is licensed under the MIT License - see the LICENSE file for details.