搜尋套件、儲存庫與 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.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。