CustomDropdownMenu<T> class

A dropdown menu that can be opened from a TextField. The selected menu item is displayed in that field.

This widget is used to help people make a choice from a menu and put the selected item into the text input field. People can also filter the list based on the text input or search one item in the menu list.

The menu is composed of a list of ZeroDropdownMenuEntrys. People can provide information, such as: label, leading icon or trailing icon for each entry. The TextField will be updated based on the selection from the menu entries. The text field will stay empty if the selected entry is disabled.

The dropdown menu can be traversed by pressing the up or down key. During the process, the corresponding item will be highlighted and the text field will be updated. Disabled items will be skipped during traversal.

The menu can be scrollable if not all items in the list are displayed at once.

{@tool dartpad} This sample shows how to display outlined CustomDropdownMenu and filled CustomDropdownMenu.

** See code in examples/api/lib/material/dropdown_menu/dropdown_menu.0.dart ** {@end-tool}

See also:

Inheritance

Constructors

CustomDropdownMenu.new({Key? key, bool enabled = true, double? width, double? menuHeight, Widget? leadingIcon, Widget? trailingIcon, Widget? label, String? hintText, Widget? selectedTrailingIcon, bool enableFilter = false, bool enableSearch = true, TextStyle? textStyle, InputDecorationTheme? inputDecorationTheme, ZeroMenuStyle? menuStyle, TextEditingController? controller, T? initialSelection, ValueChanged<T?>? onSelected, required List<ZeroDropdownMenuEntry<T>> dropdownMenuEntries})
Creates a const CustomDropdownMenu.
const

Properties

controller TextEditingController?
Controls the text being edited or selected in the menu.
final
Descriptions of the menu items in the CustomDropdownMenu.
final
enabled bool
Determine if the CustomDropdownMenu is enabled.
final
enableFilter bool
Determine if the menu list can be filtered by the text input.
final
enableSearch bool
Determine if the first item that matches the text input can be highlighted.
final
hashCode int
The hash code for this object.
no setterinherited
hintText String?
Text that suggests what sort of input the field accepts.
final
initialSelection → T?
The value used to for an initial selection.
final
inputDecorationTheme InputDecorationTheme?
Defines the default appearance of InputDecoration to show around the text field.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label Widget?
Optional widget that describes the input field.
final
leadingIcon Widget?
An optional Icon at the front of the text input field.
final
Determine the height of the menu.
final
The MenuStyle that defines the visual attributes of the menu.
final
onSelected ValueChanged<T?>?
The callback is called when a selection is made.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectedTrailingIcon Widget?
An optional icon at the end of the text field to indicate that the text field is pressed.
final
textStyle TextStyle?
The text style for the TextField of the CustomDropdownMenu;
final
trailingIcon Widget?
An optional icon at the end of the text field.
final
width double?
Determine the width of the CustomDropdownMenu.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<CustomDropdownMenu<T>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited