flutter_easy_dropdown 1.0.4 copy "flutter_easy_dropdown: ^1.0.4" to clipboard
flutter_easy_dropdown: ^1.0.4 copied to clipboard

Simple and robust Searchable Dropdown with item search feature, making it possible to use an offline item list or filtering URL for easy customization.

Flutter Easy DropdownSearch #

Flutter pub package likes popularity pub points

A powerful and flexible Flutter dropdown search widget with pagination support, built on top of dropdown_search. This package provides an enhanced dropdown experience with features like network API integration, pagination, and customizable UI.

Dropdown search demo

✨ Features #

  • πŸ”„ Pagination Support: Load data in chunks for better performance
  • 🌐 Network Integration: Fetch data from APIs with ease
  • πŸ” Searchable: Built-in search functionality
  • 🎨 Multiple Display Modes:
    • Menu
    • BottomSheet
    • ModalBottomSheet
    • Dialog
  • βœ… Selection Types:
    • Single selection
    • Multi-selection
  • 🎯 Customizable UI: Match your app's theme
  • πŸŒ“ Theme Support: Works with both light and dark themes
  • πŸ“± StatelessWidget Support: Easy implementation
  • πŸ—οΈ Multi-level Items: Support for hierarchical data

πŸ“Έ Screenshots #

Example 1 Example 2
Example 3 Example 4

πŸ“¦ Installation #

Add the following to your pubspec.yaml:

dependencies:
  flutter_easy_dropdown: ^latest_version

πŸš€ Quick Start #

Basic Usage #

import 'package:flutter_easy_dropdown/flutter_easy_dropdown.dart';

DropdownSearch<String>(
  popupProps: PopupProps.menu(
    showSelectedItems: true,
    disabledItemFn: (String s) => s.startsWith('I'),
  ),
  items: ["Brazil", "Italia (Disabled)", "US", 'Canada'],
  dropdownDecoratorProps: DropDownDecoratorProps(
    dropdownSearchDecoration: InputDecoration(
      labelText: "Menu mode",
      hintText: "country in menu mode",
    ),
  ),
  onChanged: print,
  selectedItem: "Brazil",
)

Multi-Selection Example #

DropdownSearch<String>.multiSelection(
  items: ["Brazil", "Italia (Disabled)", "London", 'Canada'],
  popupProps: PopupPropsMultiSelection.menu(
    showSelectedItems: true,
    disabledItemFn: (String s) => s.startsWith('I'),
  ),
  onChanged: print,
  selectedItems: ["Brazil"],
)

πŸ”§ Advanced Usage #

Custom Item Display #

DropdownSearch<UserModel>(
  asyncItems: (String filter) => getData(filter),
  itemAsString: (UserModel u) => u.userAsStringByName(),
  onChanged: (UserModel? data) => print(data),
  dropdownDecoratorProps: DropDownDecoratorProps(
    dropdownSearchDecoration: InputDecoration(labelText: "User by name"),
  ),
)

Custom Filter Function #

DropdownSearch<UserModel>(
  filterFn: (user, filter) => user.userFilterByCreationDate(filter),
  asyncItems: (String filter) => getData(filter),
  itemAsString: (UserModel u) => u.userAsStringByName(),
  onChanged: (UserModel? data) => print(data),
  dropdownDecoratorProps: DropDownDecoratorProps(
    dropdownSearchDecoration: InputDecoration(labelText: "Name"),
  ),
)

API Integration Example #

DropdownSearch<UserModel>(
  dropdownSearchDecoration: InputDecoration(labelText: "Name"),
  asyncItems: (String filter) async {
    var response = await Dio().get(
      "http://5d85ccfb1e61af001471bf60.mockapi.io/user",
      queryParameters: {"filter": filter},
    );
    var models = UserModel.fromJsonList(response.data);
    return models;
  },
  onChanged: (UserModel? data) {
    print(data);
  },
)

Form Validation #

DropdownSearch(
  items: ["Brazil", "France", "Tunisia", "Canada"],
  dropdownSearchDecoration: InputDecoration(labelText: "Name"),
  onChanged: print,
  selectedItem: "Tunisia",
  validator: (String? item) {
    if (item == null)
      return "Required field";
    else if (item == "Brazil")
      return "Invalid item";
    else
      return null;
  },
)

🀝 Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.

⭐ Support #

If you find this package useful, please consider giving it a star on GitHub. Your support helps us maintain and improve the package!

5
likes
160
points
15
downloads

Publisher

verified publishertherohitsoni.in

Weekly Downloads

Simple and robust Searchable Dropdown with item search feature, making it possible to use an offline item list or filtering URL for easy customization.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dio, flutter, pagination_view

More

Packages that depend on flutter_easy_dropdown