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

dropdown_below 封面
插件详情v1.0.3

dropdown_below

Flutter 自定义下拉框。开发者可以根据自己的喜好自定义许多选项。这对下拉框的用户体验来说是一个巨大的优势。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1090
喜欢数
71
Pub 分数
140

安装插件

flutter pub add dropdown_below

插件介绍

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

一个可自定义的 Flutter 下拉菜单小部件,将选项显示在输入字段下方,通过灵活的样式和行为提升用户体验。开发者可以调整外观、动画和交互,以匹配其应用的设计。非常适合对空间和美观性有要求的表单和选择界面。该包支持所有主要平台,确保在各种设备上行为一致。

适合场景

  • 带下拉菜单的表单输入
  • 可自定义的选择菜单
  • 移动和网页用户界面增强
  • 动态表单字段
  • 注重可访问性的设计

主要特点

  • 位于输入框下方
  • 高度可定制的外观
  • 跨平台兼容性
  • 流畅的动画
  • 可扩展的 API
  • 对自定义组件的支持

适合对象

  • UI/UX 设计师
  • Flutter 开发者
  • 表单密集型应用
  • 需要定制下拉菜单的应用程序
  • 具有严格设计规范的项目

使用建议

  • 需要手动处理状态
  • 有限的内置验证
  • 复杂布局可能需要额外的样式
  • 未针对超长列表进行优化
  • 依赖外部依赖项以实现高级功能

原始 README

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

Flutter Dropdown_Below

A Flutter Dropdown library which is customize flutter dropdownbutton widget.

license license license

Options

options description type required
itemWidth dropdown item's box width double X
itemTextstyle dropdown item's text style double X
boxTextstyle seletced box text style TextStyle X
boxPadding seletced box inner padding EdgeInsetsGeometry X
boxHeight seletced box height double X
boxWidth seletced box width double X
hint text before you choose item Widget X
value selected item T X
boxDecoration box's border, borderRadius, color BoxDecoration X
icon widget which is right beside Widget X
items itemsList List<DropdownMenuItem> O
onChange change item function ValueChanged O

How to make it Work?

Description for example.
1. datas

_testList's type is always be a list.

If you want to use map or other type, you can customize this package.

  List _testList = [{'no': 1, 'keyword': 'blue'},{'no': 2, 'keyword': 'black'},{'no': 3, 'keyword': 'red'}];
  List<DropdownMenuItem> _dropdownTestItems;
  var _selectedTest;
2. initState & build items to correct type

If you want to customize item's child widget ex) Text -> Container, You can change any widget you want.

  @override
  void initState() {
    _dropdownTestItems = buildDropdownTestItems(_testList);
    super.initState();
  }

  List<DropdownMenuItem> buildDropdownTestItems(List _testList) {
    List<DropdownMenuItem> items = List();
    for (var i in _testList) {
      items.add(
        DropdownMenuItem(
          value: i,
          child: Text(i['keyword']),
        ),
      );
    }
    return items;
  }
3. change function
  onChangeDropdownTests(selectedTest) {
    print(selectedTest);
    setState(() {
      _selectedTest = selectedTest;
    });
  }
4. UI

Dropdown Widget.

    DropdownBelow(
      itemWidth: 200,
      itemTextstyle: TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: Colors.black),
      boxTextstyle: TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: Color(0XFFbbbbbb)),
      boxPadding: EdgeInsets.fromLTRB(13, 12, 0, 12),
      boxHeight: 45,
      boxWidth: 200,
      hint: Text('choose item'),
      value: _selectedTest,
      items: _dropdownTestItems,
      onChanged: onChangeDropdownTests,
    ),
5. Question

IF you want to make itemBox dropdown when you enter the page?

Put this code to initState like this.

Timer(Duration(milliseconds: 200), () {
    CustomDropdownButtonState state = dropdownKey1.currentState;
    state.callTap();
});

And put key to Widget like this.

DropdownBelow(
  key: dropdownKey1,
  itemWidth: 200,
  itemTextstyle: TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: Colors.black),
  boxTextstyle: TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: Color(0XFFbbbbbb)),
  boxPadding: EdgeInsets.fromLTRB(13, 12, 0, 12),
  boxHeight: 45,
  boxWidth: 200,
  hint: Text('choose item'),
  value: _selectedTest,
  items: _dropdownTestItems,
  onChanged: onChangeDropdownTests,
)

Actually, dropdown widget is made by Navigation. So, it can work.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。