DropdownMenu<T> constructor
- Key? key,
- bool enabled = true,
- double? width,
- Widget? leadingIcon,
- Widget? trailingIcon,
- bool showTrailingIcon = true,
- Widget? label,
- String? hintText,
- String? helperText,
- String? errorText,
- Widget? selectedTrailingIcon,
- bool enableFilter = false,
- bool enableSearch = true,
- TextInputType? keyboardType,
- TextStyle? textStyle,
- TextAlign textAlign = TextAlign.start,
- Object? inputDecorationTheme,
- TextEditingController? controller,
- T? initialSelection,
- ValueChanged<
T?> ? onSelected, - FocusNode? focusNode,
- bool? requestFocusOnTap,
- EdgeInsetsGeometry? expandedInsets,
- FilterCallback<
T> ? filterCallback, - SearchCallback<
T> ? searchCallback, - Offset? alignmentOffset,
- required List<
DropdownMenuEntry< dropdownMenuEntries,T> > - List<
TextInputFormatter> ? inputFormatters, - DropdownMenuCloseBehavior closeBehavior = DropdownMenuCloseBehavior.all,
- int? maxLines = 1,
- TextInputAction? textInputAction,
- String? restorationId,
Creates a const DropdownMenu.
The leading and trailing icons in the text field can be customized by using
leadingIcon
, trailingIcon
and selectedTrailingIcon
properties. They are
passed down to the InputDecoration properties, and will override values
in the InputDecoration.prefixIcon and InputDecoration.suffixIcon.
Except leading and trailing icons, the text field can be configured by the
inputDecorationTheme
property. The menu can be configured by the menuStyle
.
Implementation
const DropdownMenu({
super.key,
this.enabled = true,
this.width,
this.menuHeight,
this.leadingIcon,
this.trailingIcon,
this.showTrailingIcon = true,
this.label,
this.hintText,
this.helperText,
this.errorText,
this.selectedTrailingIcon,
this.enableFilter = false,
this.enableSearch = true,
this.keyboardType,
this.textStyle,
this.textAlign = TextAlign.start,
// TODO(bleroux): Clean this up once `InputDecorationTheme` is fully normalized.
Object? inputDecorationTheme,
this.menuStyle,
this.controller,
this.initialSelection,
this.onSelected,
this.focusNode,
this.requestFocusOnTap,
this.expandedInsets,
this.filterCallback,
this.searchCallback,
this.alignmentOffset,
required this.dropdownMenuEntries,
this.inputFormatters,
this.closeBehavior = DropdownMenuCloseBehavior.all,
this.maxLines = 1,
this.textInputAction,
this.restorationId,
}) : assert(filterCallback == null || enableFilter),
assert(
inputDecorationTheme == null ||
(inputDecorationTheme is InputDecorationTheme ||
inputDecorationTheme is InputDecorationThemeData),
),
_inputDecorationTheme = inputDecorationTheme;