DropdownButton2<T> constructor
- {Key? key,
- required List<
DropdownMenuItem< ? items,T> > - DropdownButtonBuilder? selectedItemBuilder,
- T? value,
- Widget? hint,
- Widget? disabledHint,
- ValueChanged<
T?> ? onChanged, - OnMenuStateChangeFn? onMenuStateChange,
- TextStyle? style,
- Widget? underline,
- bool isDense = false,
- bool isExpanded = false,
- FocusNode? focusNode,
- bool autofocus = false,
- bool? enableFeedback,
- AlignmentGeometry alignment = AlignmentDirectional.centerStart,
- ButtonStyleData? buttonStyleData,
- IconStyleData iconStyleData = const IconStyleData(),
- DropdownStyleData dropdownStyleData = const DropdownStyleData(),
- DropdownSearchData<
T> ? dropdownSearchData, - Widget? customButton,
- bool openWithLongPress = false,
- bool barrierDismissible = true,
- Color? barrierColor,
- String? barrierLabel}
Creates a DropdownButton2 It's customizable DropdownButton with steady dropdown menu and many other features.
The items must have distinct values. If value isn't null then it must be equal to one of the DropdownMenuItem values. If items or onChanged is null, the button will be disabled, the down arrow will be greyed out.
If value is null and the button is enabled, hint will be displayed if it is non-null.
If value is null and the button is disabled, disabledHint will be displayed if it is non-null. If disabledHint is null, then hint will be displayed if it is non-null.
Implementation
DropdownButton2({
super.key,
required this.items,
this.selectedItemBuilder,
this.value,
this.hint,
this.disabledHint,
this.onChanged,
this.onMenuStateChange,
this.style,
this.underline,
this.isDense = false,
this.isExpanded = false,
this.focusNode,
this.autofocus = false,
this.enableFeedback,
this.alignment = AlignmentDirectional.centerStart,
this.buttonStyleData,
this.iconStyleData = const IconStyleData(),
this.dropdownStyleData = const DropdownStyleData(),
this.menuItemStyleData = const MenuItemStyleData(),
this.dropdownSearchData,
this.customButton,
this.openWithLongPress = false,
this.barrierDismissible = true,
this.barrierColor,
this.barrierLabel,
// When adding new arguments, consider adding similar arguments to
// DropdownButtonFormField.
}) : assert(
items == null ||
items.isEmpty ||
value == null ||
items.where((DropdownMenuItem<T> item) {
return item.value == value;
}).length ==
1,
"There should be exactly one item with [DropdownButton]'s value: "
'$value. \n'
'Either zero or 2 or more [DropdownMenuItem]s were detected '
'with the same value',
),
assert(
menuItemStyleData.customHeights == null ||
items == null ||
items.isEmpty ||
menuItemStyleData.customHeights?.length == items.length,
"customHeights list should have the same length of items list",
),
formFieldCallBack = null;