MenuAnchor class
A widget used to mark the "anchor" for a set of submenus, defining the rectangle used to position the menu, which can be done either with an explicit location, or with an alignment.
When creating a menu with MenuBar or a SubmenuButton, a MenuAnchor is not needed, since they provide their own internally.
The MenuAnchor is meant to be a slightly lower level interface than MenuBar, used in situations where a MenuBar isn't appropriate, or to construct widgets or screen regions that have submenus.
To create a local project with this code sample, run:
flutter create --sample=material.MenuAnchor.1 mysample
To create a local project with this code sample, run:
flutter create --sample=material.MenuAnchor.2 mysample
To create a local project with this code sample, run:
flutter create --sample=material.MenuAnchor.3 mysample
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- MenuAnchor
Constructors
- MenuAnchor({Key? key, MenuController? controller, FocusNode? childFocusNode, MenuStyle? style, Offset? alignmentOffset = Offset.zero, LayerLink? layerLink, Clip clipBehavior = Clip.hardEdge, @Deprecated('Use consumeOutsideTap instead. ' 'This feature was deprecated after v3.16.0-8.0.pre.') bool anchorTapClosesMenu = false, bool consumeOutsideTap = false, VoidCallback? onOpen, VoidCallback? onClose, bool crossAxisUnconstrained = true, MenuAnchorChildBuilder? builder, Widget? child})
-
Creates a const MenuAnchor.
const
Properties
- alignmentOffset → Offset?
-
The offset of the menu relative to the alignment origin determined by
MenuStyle.alignment on the style attribute and the ambient
Directionality.
final
- anchorTapClosesMenu → bool
-
Whether the menus will be closed if the anchor area is tapped.
final
- builder → MenuAnchorChildBuilder?
-
The widget that this MenuAnchor surrounds.
final
- child → Widget?
-
The optional child to be passed to the builder.
final
- childFocusNode → FocusNode?
-
The childFocusNode attribute is the optional FocusNode also associated
to the child or builder widget that opens the menu.
final
- clipBehavior → Clip
-
The content will be clipped (or not) according to this option.
final
- consumeOutsideTap → bool
-
Whether or not a tap event that closes the menu will be permitted to
continue on to the gesture arena.
final
- controller → MenuController?
-
An optional controller that allows opening and closing of the menu from
other widgets.
final
- crossAxisUnconstrained → bool
-
Determine if the menu panel can be wrapped by a UnconstrainedBox which allows
the panel to render at its "natural" size.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- layerLink → LayerLink?
-
An optional LayerLink to attach the menu to the widget that this
MenuAnchor surrounds.
final
-
A list of children containing the menu items that are the contents of the
menu surrounded by this MenuAnchor.
final
- onClose → VoidCallback?
-
A callback that is invoked when the menu is closed.
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
- style → MenuStyle?
-
The MenuStyle that defines the visual attributes of the menu bar.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< MenuAnchor> -
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
-
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