MacosPopupButton<T> class

A macOS-style pop-up button.

A pop-up button (often referred to as a pop-up menu) is a type of button that, when clicked, displays a menu containing a list of mutually exclusive choices. A pop-up button includes a double-arrow indicator that alludes to the direction in which the menu will appear (only vertical is currently supported).

The type T is the type of the value that each popup item represents. All the entries in a given menu must represent values with consistent types. Typically, an enum is used. Each MacosPopupMenuItem in items must be specialized with that same type argument.

The onChanged callback should update a state variable that defines the popup's value. It should also call State.setState to rebuild the popup with the new value.

If the onChanged callback is null or the list of items is null then the popup button will be disabled, i.e. its arrow will be displayed in grey and it will not respond to input. A disabled button will display the disabledHint widget if it is non-null. However, if disabledHint is null and hint is non-null, the hint widget will instead be displayed.

See also:

Inheritance

Constructors

MacosPopupButton({Key? key, required List<MacosPopupMenuItem<T>>? items, MacosPopupButtonBuilder? selectedItemBuilder, T? value, Widget? hint, Widget? disabledHint, required ValueChanged<T?>? onChanged, VoidCallback? onTap, TextStyle? style, double? itemHeight = _kMinInteractiveDimension, FocusNode? focusNode, bool autofocus = false, Color? popupColor, double? menuMaxHeight, AlignmentGeometry alignment = AlignmentDirectional.centerStart})
Creates a macOS-style popup button.

Properties

alignment AlignmentGeometry
Defines how the hint or the selected item is positioned within the button.
final
autofocus bool
True if this widget will be selected as the initial focus when no other node in its scope is currently focused.
final
disabledHint Widget?
A preferred placeholder widget that is displayed when the popup is disabled.
final
focusNode FocusNode?
An optional focus node to use as the focus node for this widget.
final
hashCode int
The hash code for this object.
no setterinherited
hint Widget?
A placeholder widget that is displayed by the popup button.
final
itemHeight double?
If null, then the menu item heights will vary according to each menu item's intrinsic height.
final
items List<MacosPopupMenuItem<T>>?
The list of items the user can select.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
The maximum height of the menu.
final
onChanged ValueChanged<T?>?
Called when the user selects an item.
final
onTap VoidCallback?
Called when the popup button is tapped.
final
popupColor Color?
The background color of the popup.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectedItemBuilder MacosPopupButtonBuilder?
A builder to customize the popup buttons corresponding to the MacosPopupMenuItems in items.
final
style TextStyle?
The text style to use for text in the popup button and the popup menu that appears when you tap the button.
final
value → T?
The value of the currently selected MacosPopupMenuItem.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<MacosPopupButton<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.
override
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}) 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