searchable_textfeild 0.1.0
searchable_textfeild: ^0.1.0 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 customizable Flutter widget that combines the functionality of a TextField with dropdown search capabilities.
Features #
- Standard TextField functionality
- Dropdown with search functionality
- API-based search support
- Pagination for large datasets
- Customizable appearance
- Form validation support
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 #
Add this to your package's pubspec.yaml file:
dependencies:
searchable_textfield: ^latest_version
Usage #
Basic example:
SearchableTextField(
controller: TextEditingController(),
enabled: true,
isDropdown: true,
isObscured: false,
items: [
DropdownMenuItems(lable: "Item 1", value: "1"),
DropdownMenuItems(lable: "Item 2", value: "2"),
],
onChanged: (value) {
print("Selected value: $value");
},
)
API-based search example:
SearchableTextField(
controller: TextEditingController(),
enabled: true,
isDropdown: true,
isObscured: false,
getItems: ({page, filter, limit}) async {
// Implement your API call here
return yourApiCall(page: page, searchText: filter, pageSize: limit);
},
onChanged: (value) {
print("Selected value: $value");
},
)
API Reference #
Main Properties #
controller: TextEditingController for managing the text inputenabled: Enables/disables the text fieldisDropdown: Enables dropdown functionalityitems: List of predefined dropdown itemsgetItems: Function for API-based item fetchingonChanged: Callback for value changesvalidator: Form validation functionisObscured: Toggle password visibilitytextFeildDecorator: Custom input decorationdropdownDecoration: Custom BoxDecoration for dropdown containerdropdownItemStyle: TextStyle for dropdown itemsdropdownBackgroundColor: Background color of dropdowndropdownItemPadding: Padding for dropdown itemsdropdownElevation: Elevation of dropdown container
Usage with Custom Styling #
SearchableTextField(
controller: TextEditingController(),
enabled: true,
isDropdown: true,
isObscured: false,
items: [
DropdownMenuItems(lable: "Item 1", value: "1"),
DropdownMenuItems(lable: "Item 2", value: "2"),
],
dropdownDecoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.grey),
),
dropdownItemStyle: TextStyle(
color: Colors.blue,
fontSize: 16,
),
dropdownBackgroundColor: Colors.grey[100],
dropdownItemPadding: EdgeInsets.symmetric(
horizontal: 20,
vertical: 15,
),
dropdownElevation: 4,
onChanged: (value) {
print("Selected value: $value");
},
)
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
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.