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.


Creates a const SubmenuButton.


alignmentOffset Offset?
The offset of the menu relative to the alignment origin determined by MenuStyle.alignment on the style attribute.
child Widget?
The widget displayed in the middle portion of this button.
clipBehavior Clip
The content will be clipped (or not) according to this option.
controller MenuController?
An optional MenuController for this submenu.
focusNode FocusNode?
An optional focus node to use as the focus node for this widget.
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
leadingIcon Widget?
An optional icon to display before the child.
The list of widgets that appear in the menu when it is opened.
The MenuStyle of the menu specified by menuChildren.
onClose VoidCallback?
A callback that is invoked when the menu is closed.
onFocusChange ValueChanged<bool>?
Handler called when the focus changes.
onHover ValueChanged<bool>?
Called when a pointer enters or exits the button response area.
onOpen VoidCallback?
A callback that is invoked when the menu is opened.
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.
style ButtonStyle?
Customizes this button's appearance.
trailingIcon Widget?
An optional icon to display after the child.


createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
createState() State<SubmenuButton>
Creates the mutable state for this widget at a given location in the tree.
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
defaultStyleOf(BuildContext context) ButtonStyle
Defines the button's default appearance.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
themeStyleOf(BuildContext context) ButtonStyle?
Returns the 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.
toString({DiagnosticLevel minLevel =}) String
A string representation of this object.
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
toStringShort() String
A short, textual description of this widget.


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

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.