build method
Builds a widget that positions the menu panel child using the provided
position information.
Implementation
@override
Widget build(BuildContext context, RawMenuOverlayInfo position, Widget child) {
final alignment =
anchorAttachment ??
switch (BaseMenu.maybeOrientationOf(context)) {
Axis.vertical => AlignmentDirectional.topEnd,
_ => AlignmentDirectional.bottomStart,
};
final resolvedOffset =
useDirectionalOffset && Directionality.maybeOf(context) == TextDirection.rtl
? Offset(-offset.dx, offset.dy)
: offset;
final enableAim = enableAimAssist ?? MenuAimScope.maybeOf(context)?.enable ?? false;
if (enableAim) {
return _AimAssistBuilder(
builder: (context, geometry) {
geometry.anchorRect = position.anchorRect;
return _MenuPositioner(
overlayPadding: overlayPadding,
menuPadding: padding,
anchorRect: position.anchorRect,
offset: resolvedOffset,
menuPosition: position.position,
menuAlignment: menuAttachment ?? AlignmentDirectional.topStart,
alignment: alignment,
edgeBehavior: edgeBehavior,
onPositioned: (targetRect) {
geometry.targetRect = targetRect;
},
child: child,
);
},
);
} else {
return _MenuPositioner(
overlayPadding: overlayPadding,
menuPadding: padding,
anchorRect: position.anchorRect,
offset: resolvedOffset,
menuPosition: position.position,
menuAlignment: menuAttachment ?? AlignmentDirectional.topStart,
alignment: alignment,
edgeBehavior: edgeBehavior,
child: child,
);
}
}