SubmenuButton class

A menu button that displays a cascading menu.

It can be used as part of a MenuBar, or as a standalone widget.

This widget represents a menu item that has a submenu. Like the leaf MenuItemButton, it shows a label with an optional leading or trailing icon, but additionally shows an arrow icon showing that it has a submenu.

By default the submenu will appear to the side of the controlling button. The alignment and offset of the submenu can be controlled by setting MenuStyle.alignment on the style and the alignmentOffset argument, respectively.

When activated (by being clicked, through keyboard navigation, or via hovering with a mouse), it will open a submenu containing the menuChildren.

If menuChildren is empty, then this menu item will appear disabled.

See also:

  • MenuItemButton, a widget that represents a leaf menu item that does not host a submenu.
  • MenuBar, a widget that renders menu items in a row in a Material Design style.
  • MenuAnchor, a widget that creates a region with a submenu and shows it when requested.
  • PlatformMenuBar, a widget that renders similar menu bar items from a PlatformMenuItem using platform-native APIs instead of Flutter.
Inheritance

Constructors

Creates a const SubmenuButton.
const

Properties

alignmentOffset Offset?
The offset of the menu relative to the alignment origin determined by MenuStyle.alignment on the style attribute.
final
child Widget?
The widget displayed in the middle portion of this button.
final
clipBehavior Clip
The content will be clipped (or not) according to this option.
final
controller MenuController?
An optional MenuController for this submenu.
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
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
leadingIcon Widget?
An optional icon to display before the child.
final
The list of widgets that appear in the menu when it is opened.
final
The MenuStyle of the menu specified by menuChildren.
final
onClose VoidCallback?
A callback that is invoked when the menu is closed.
final
onFocusChange ValueChanged<bool>?
Handler called when the focus changes.
final
onHover ValueChanged<bool>?
Called when a pointer enters or exits the button response area.
final
onOpen VoidCallback?
A callback that is invoked when the menu is opened.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statesController MaterialStatesController?
Represents the interactive "state" of this widget in terms of a set of MaterialStates, like MaterialState.pressed and MaterialState.focused.
final
style ButtonStyle?
Customizes this button's appearance.
final
trailingIcon Widget?
An optional icon to display after the child.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<SubmenuButton>
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.
override
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
override
defaultStyleOf(BuildContext context) ButtonStyle
Defines the button's default appearance.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
themeStyleOf(BuildContext context) ButtonStyle?
Returns the MenuButtonThemeData.style of the closest MenuButtonTheme ancestor.
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

Static Methods

styleFrom({Color? foregroundColor, Color? backgroundColor, Color? disabledForegroundColor, Color? disabledBackgroundColor, Color? shadowColor, Color? surfaceTintColor, Color? iconColor, TextStyle? textStyle, double? elevation, EdgeInsetsGeometry? padding, Size? minimumSize, Size? fixedSize, Size? maximumSize, MouseCursor? enabledMouseCursor, MouseCursor? disabledMouseCursor, BorderSide? side, OutlinedBorder? shape, VisualDensity? visualDensity, MaterialTapTargetSize? tapTargetSize, Duration? animationDuration, bool? enableFeedback, AlignmentGeometry? alignment, InteractiveInkFeatureFactory? splashFactory}) ButtonStyle
A static convenience method that constructs a SubmenuButton's ButtonStyle given simple values.