平台 | 是否支持 |
---|---|
Android | ✔️ |
IOS | ✔️ |
Web | ✔️ |
Macos | ✔️ |
Windows | ✔️ |
Linux | ✔️ |
Getting started :
Github
pub.dev
将package依赖添加到 pubspec.yaml
:
dependencies:
dropdown_button_plus: 0.0.2
import 'package:dropdown_button_plus/dropdown_plus.dart' as plus;
基础用法和 Flutter SDK 的 DropdownButton一样。
plus.DropdownView(
items: filters,
itemPadding: EdgeInsets.zero,
itemBuilder: (_, index, select) => ItemMenuString(
label: filters[index],
select: select,
showIndicator: false,
mainAxisAlignment: MainAxisAlignment.center,
),
selectedItemBuilder: (_, index, select) => ItemMenuHeader(
label: filters[index],
select: select,
),
hintBuilder: (context, focus) => HintWidgetBuilder(
'Dropdown',
focus: focus,
),
),
plus.DropdownView(
isDropdown: true,
items: filters,
itemPadding: EdgeInsets.zero,
itemBuilder: (_, index, select) => ItemMenuString(
label: filters[index],
select: select,
showIndicator: false,
mainAxisAlignment: MainAxisAlignment.center,
),
selectedItemBuilder: (_, index, select) => ItemMenuHeader(
label: filters[index],
select: select,
),
hintBuilder: (context, focus) => HintWidgetBuilder(
'Pinned',
focus: focus,
),
),
plus.DropdownView(
onChanged: widget.onType,
forceWidth: true,
isDropdown: true,
isOutsideShadow: true,
isPinnedSelected: false,
items: filters,
itemBuilder: (_, index, select) => ItemMenuString(
label: filters[index],
select: select,
),
selectedItemBuilder: (_, index, select) => ItemMenuHeader(
label: '综合排序',
select: select,
),
hintBuilder: (context, focus) => HintWidgetBuilder(
'综合排序',
focus: focus,
),
),
SizedBox(
height: kMinInteractiveDimension,
child: DropdownView(
forceWidth: true,
isDropdown: true,
isOutsideShadow: true,
isPinnedSelected: false,
itemPadding: EdgeInsets.zero,
itemHeight: MediaQuery.of(context).size.height / 2,
items: const [''],
itemBuilder: (_, index, select) => ItemMenuOption(
onChanged: widget.onOption,
),
selectedItemBuilder: (_, index, select) => ItemMenuHeader(
label: '对账单',
select: select,
),
hintBuilder: (context, focus) => HintWidgetBuilder(
'对账单',
focus: focus,
padding: const EdgeInsets.only(top: kMinInteractiveDimension / 8),
),
),
),