搜索插件、代码仓与 APP 分类

插件详情v2.0.0

extendable_dropdown

ExtendableDropdown 是一个功能强大的 Flutter 包,用于创建动态且可自定义的下拉菜单

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
35
喜欢数
2
Pub 分数
155

安装插件

flutter pub add extendable_dropdown

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

ExtendableDropdown 是一个灵活的 Flutter 包,可在多个平台上创建动态且可自定义的下拉菜单。它支持单选和多选,使开发者能够轻松地定制下拉菜单的外观和行为。该包可无缝集成到 Flutter 应用中,提供流畅的动画和响应式设计。支持 Android、iOS、Web、macOS、Windows 和 Linux,确保在各种设备上提供一致的用户体验。适用于表单、筛选器和设置界面,通过直观的交互模式提升可用性。

适合场景

  • 表单输入
  • 筛选数据
  • 用户偏好
  • 设置面板
  • 动态选择列表
  • 多选下拉菜单

主要特点

  • 可自定义样式
  • 多选支持
  • 流畅的动画
  • 跨平台兼容性
  • 响应式设计
  • 轻松集成

适合对象

  • 开发表单的开发者
  • 寻求灵活性的UI设计师
  • 需要动态筛选的应用程序
  • 跨平台 Flutter 项目
  • 交互式用户界面

使用建议

  • 可能需要额外的样式来适应复杂布局
  • 大数据集的性能影响
  • 有限的内置验证
  • 未针对极长列表进行优化
  • 需要仔细的状态管理
  • 依赖外部依赖项以实现高级功能

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

ExtendableDropdown

A Versatile Flutter Package for Dynamic, Generic Dropdown Menus (v1.0.4)

Introducing ExtendableDropdown, a production-ready Flutter package that empowers you to create dynamic and expandable multiple dropdown menus with full support for generic data types.

🚀 Key Features

  • Generic Type Support: Handle any data type (T) with full type safety. No longer restricted to strings!
  • Dynamic Slot Management: Add or remove dropdown slots on the fly with a simple, intuitive UI.
  • Dismissible Interaction: Swipe-to-dismiss functionality for removing selections with item return logic.
  • labelBuilder API: Complete control over how your custom objects are rendered as text in the dropdown.
  • Configurable UI Fragments: Pass your own Widgets for the Add Button and custom callbacks for message handling.
  • Fully Mutable-Safe: Built with immutability in mind, following Flutter's best practices for widget design.

📦 Installation

Add extendable_dropdown as a dependency in your pubspec.yaml file:

dependencies:
  extendable_dropdown: ^1.0.4

Import the package in your Flutter code:

import 'package:extendable_dropdown/extendable_dropdown.dart';

🛠 Usage

Simple Usage (Strings)
List<String> cities = ['Colombo', 'Kandy', 'Galle', 'Jaffna'];

ExtendableDropdown<String>(
  list: cities,
  onSendListChanged: (selectedItems) {
    print('Selected cities: $selectedItems');
  },
)
Advanced Usage (Custom Objects & UI)

You can use any custom model and fully override the UI.

ExtendableDropdown<Location>(
  list: myLocationList,
  onSendListChanged: (selected) => print(selected),
  labelBuilder: (location) => location.name,
  // Completely custom add button
  addButton: ElevatedButton.icon(
    onPressed: null, // Logic is handled internally
    icon: Icon(Icons.add),
    label: Text("Add Location"),
  ),
  // Custom notification logic
  onMessage: (context, message) {
    MyCustomToast.show(message);
  },
)

🎨 Professional Customization

ExtendableDropdown comes with a wide range of styling options:

Property Description Default
list The initial list of items to choose from. Required
onSendListChanged Callback triggered when the selection changes. Required
labelBuilder Function to map generic items to strings. item.toString()
addButton Widget: Custom widget for the add button. Styled default button
onMessage Callback: Handle custom alerts/notifications. Default SnackBar
dismissibleBackgroundColor Color shown when swiping to delete. Colors.red
selectedIcon Icon shown for a selected slot. Icons.radio_button_checked
nonSelectedIcon Icon shown for an empty slot. Icons.location_on_outlined
dropdownBorderRadius Border radius of the dropdown container. 10.0
Check out the [example](file:///Users/mymac/Documents/MyProjects/extendable_dropdown/example/lib/main.dart) folder for a full implementation!

🚧 Roadmap

  • [x] Generic data type support (Completed)
  • [x] Improved state management and immutability (Completed)
  • [ ] Searchable dropdown options
  • [ ] Multi-select within a single dropdown slot
  • [ ] Custom animation support for slot addition

🤝 Contributing

We welcome your feedback and contributions! Please feel free to open issues or submit pull requests.

📄 License

This project is licensed under the MIT License - see the [LICENSE](file:///Users/mymac/Documents/MyProjects/extendable_dropdown/LICENSE) file for details.


Made with ❤️ by Chanuka Ranathunga

所属分类

源码仓库

使用此插件的项目

暂无相关数据。