DefaultMenuPositioningDelegate class
A delegate whose build method builds a widget that positions the menu panel of a BaseMenu.
The position is determined relative to the menu's anchor using the provided anchorAttachment, menuAttachment, and offset.
If useDirectionalOffset is true, the horizontal component of the offset is applied in the reading direction of the ambient Directionality. Otherwise, the offset is applied as-is, regardless of the ambient Directionality.
When the menu is opened with a position argument, the anchorAttachment
and offset are ignored, and the menu is positioned at the provided
RawMenuOverlayInfo.position.
If the menu panel has padding applied, the padding parameter can be used to ensure that the menu panel is offset from the anchor by the same amount of padding, which is useful for maintaining visual alignment between a submenu's items and its parent anchor.
The overlayPadding defines a minimum distance to apply between the menu overlay and the edges of the screen when the menu is open.
The edgeBehavior defines how the menu panel should be positioned when it overflows the edge of the screen.
- Implemented types
Constructors
- DefaultMenuPositioningDelegate({AlignmentGeometry? anchorAttachment, Offset offset = ui.Offset.zero, bool useDirectionalOffset = true, EdgeInsetsGeometry padding = EdgeInsets.zero, EdgeInsetsGeometry overlayPadding = const EdgeInsets.all(8), EdgeBehavior edgeBehavior = const EdgeBehavior(horizontal: EdgeBehaviorStrategy(flip: true, shift: true, constrain: true), vertical: EdgeBehaviorStrategy(flip: true, shift: true, constrain: true)), bool? enableAimAssist})
-
Creates a DefaultMenuPositioningDelegate.
const
Properties
- anchorAttachment → AlignmentGeometry?
-
The point on the anchor surface that attaches to the menu.
final
- edgeBehavior → EdgeBehavior
-
The behavior applied when the menu overflows the edge of the screen.
final
- enableAimAssist → bool?
-
Whether to enable the aim assist feature for this menu.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
The point on the menu surface that attaches to the anchor.
final
- offset → Offset
-
The offset applied to the menu relative to the anchor attachment point.
final
- overlayPadding → EdgeInsetsGeometry
-
A minimum distance to apply between the menu overlay and the edges of the
screen when the menu is open.
final
- padding → EdgeInsetsGeometry
-
The EdgeInsetsGeometry applied to the menu surface but ignored during
menu positioning.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- useDirectionalOffset → bool
-
Whether the offset is directional, meaning its horizontal component is
applied in the reading direction of the ambient Directionality.
final
Methods
-
build(
BuildContext context, RawMenuOverlayInfo position, Widget child) → Widget -
Builds a widget that positions the menu panel
childusing the providedpositioninformation.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited