flutter_easy_select 1.0.1
flutter_easy_select: ^1.0.1 copied to clipboard
A Flutter package that provides reusable widgets for single and multi-select dialogs with features like search, custom input, and pre-selection.
Flutter Easy Select #
A powerful, customizable Flutter package that simplifies item selection and filtering in your applications. Whether you need single or multi-select functionality, Flutter Easy Select provides an intuitive and elegant solution with support for both simple data types and complex objects.
Features #
- 🎯 Single Selection Mode: Simple one-item selection with a clean interface
- ✨ Multi-Selection Support: Select multiple items with ease
- 🔍 Smart Search: Built-in search functionality with customizable search properties
- ✏️ Custom Text Input: Option to add custom text entries in single selection mode
- 🎨 Customizable Item Builder: Create your own item layouts using custom widgets
- 🎭 Pre-selection Support: Initialize with pre-selected items
- 🔄 Generic Type Support: Works with both simple types and custom objects
Demo #
Installation #
Add this to your package's pubspec.yaml
file:
dependencies:
flutter_easy_select: ^1.0.1
Then run:
$ flutter pub get flutter_easy_select
Usage #
Basic String Selection #
/// Define a list of items
final List<String> _fruits = [
'Apple',
'Banana',
'Cherry',
'Date',
'Elderberry',
'Fig',
'Grape'
];
// Single Selection
final String? result = await FlutterEasySelect.single<String>(
context: context,
items: _fruits,
itemBuilder: (fruit) => ListTile(
title: Text(fruit),
leading: CircleAvatar(
child: Text(fruit[0]),
),
),
searchProperty: (fruit) => fruit,
title: 'Select a Fruit',
initialSelectedItem: _selectedFruit,
enableFreeText: false,
freeTextSelected: (value) {
print('Custom fruit entered: $value');
},
);
Complex Object Selection #
/// Define a custom class
class Country {
final String name;
final String code;
final int population;
Country({
required this.name,
required this.code,
required this.population,
});
}
/// Create a list of complex objects
final List<Country> _countries = [
Country(name: 'United States', code: 'US', population: 331002651),
Country(name: 'China', code: 'CN', population: 1439323776),
Country(name: 'India', code: 'IN', population: 1380004385),
// ... more countries
];
// Multi Selection with Complex Objects
final List<Country>? results = await FlutterEasySelect.multi<Country>(
context: context,
items: _countries,
itemBuilder: (country) => ListTile(
title: Text(country.name),
subtitle: Text('Population: ${country.population}'),
leading: CircleAvatar(
child: Text(country.code),
),
),
searchProperty: (country) => country.name,
itemIdentifier: (country) => country.code,
title: 'Select Countries',
isSearchEnabled: true,
initialSelectedItems: _selectedCountries,
);
Properties #
Common Properties #
Property | Type | Description |
---|---|---|
context | BuildContext |
Flutter build context |
items | List<T> |
List of items to display |
itemBuilder | Widget Function(T) |
Builder function for item UI |
searchProperty | String Function(T) |
Function to get searchable property |
title | String |
Dialog title |
isSearchEnabled | bool |
Enable search functionality |
Single Selection Properties #
Property | Type | Description |
---|---|---|
initialSelectedItem | T? |
Pre-selected item |
enableFreeText | bool |
Allow custom text input |
freeTextSelected | Function(String)? |
Callback for custom text entry |
Multi Selection Properties #
Property | Type | Description |
---|---|---|
initialSelectedItems | List<T>? |
Pre-selected items |
itemIdentifier | String Function(T) |
Function to get unique identifier |
Contributing #
Contributions are welcome! If you find a bug or want to contribute:
- Open an issue to discuss proposed changes
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License #
This project is licensed under the MIT License - see the LICENSE file for details.
Support #
If you find this package helpful, please give it a ⭐️ on GitHub!
For issues, feature requests, or questions, please open an issue.