clever_dropdown 1.0.1
clever_dropdown: ^1.0.1 copied to clipboard
A customizable Flutter dropdown widget with search, single & multi selection, and add-new-item support.
π¦ clever_dropdown #
A highly customizable and powerful dropdown widget for Flutter with:
- π Real-time search
- β Single & Multi-selection
- β Support for adding new items
- β‘ Async item loading
clever_dropdown
is perfect for forms, filters, settings, and searchable dropdown fields in Flutter apps β works across Android, iOS, Web, and Desktop.
π Features #
- πΉ Single-selection dropdown
- πΈ Multi-selection with checkboxes
- π Real-time filtering and search
- β Dynamic "Add new" option
- π Async data fetching
- β¨οΈ Keyboard navigation (Arrow β β + Enter)
- π§© Custom styling (radius, color, icons, borders)
π₯ Installation #
Add this to your pubspec.yaml
:
dependencies:
clever_dropdown: latest_version
π§ Usage #
β
Single Selection
CleverDropdown<String>(
items: ['Apple', 'Banana', 'Orange'],
value: 'Banana',
onChanged: (value) {
print('Selected: $value');
},
hintText: 'Select fruit',
isMultiple: false,
)
β
Multi Selection
CleverDropdown<String>(
items: ['Red', 'Green', 'Blue'],
isMultiple: true, // Make this true
initialValues: ['Red'],
onChanged: (values) {
print('Selected Colors: $values');
},
hintText: 'Select colors',
)
π§ Create New Item
CleverDropdown<String>(
...
onCreateTap: (newValue) {
print("Create tapped with value: $newValue");
// Add it to your backend or list
},
)
π§Ύ Parameters #
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
items |
List<T> |
No | [] |
List of options for dropdown |
asyncItems |
Future<List<T>> Function() |
No | null |
Fetch items asynchronously |
hintText |
String |
No | 'Select' |
Placeholder text |
isMultiple |
bool |
No | false |
Enable multi-selection |
onChanged |
void Function(dynamic) |
Yes | null |
Callback for selection changes |
onCreateTap |
void Function(String) |
No | null |
Callback for adding new item (on Enter or tap) |
itemAsString |
String Function(T) |
No | null |
Converts item to displayable string |
enableAddItem |
bool |
No | false |
Allow adding new values dynamically |
maxListHeight |
double |
No | 200.0 |
Max height of dropdown list |
smoothBorderRadius |
SmoothBorderRadius |
No | default |
Custom smooth border radius using figma_squircle |
dropdownColor |
Color |
No | Colors.white |
Dropdown background color |
borderColor |
Color |
No | Colors.grey |
Outline border color |
showDropdownOnlyOnSearch |
bool |
No | false |
Show dropdown only when user types something |