getMenuPosition static method
RelativeRect
getMenuPosition(
- BuildContext context,
- PositionCallback? positionCallBack,
- MenuAlign? align,
- BoxConstraints constraints,
- EdgeInsets? margin,
Implementation
static RelativeRect getMenuPosition(
BuildContext context, // /!\ should be dropdownSearch context !
PositionCallback? positionCallBack,
MenuAlign? align,
BoxConstraints constraints,
EdgeInsets? margin,
) {
//handle menu margin
// Here we get the render object of our physical button, later to get its size & position
final dropdownBox = context.findRenderObject() as RenderBox;
// Get the render object of the overlay used in `Navigator` / `MaterialApp`, i.e. screen size reference
var overlayBox =
Overlay.of(context).context.findRenderObject() as RenderBox;
if (positionCallBack != null) {
return positionCallBack(dropdownBox, overlayBox).addMargin(margin);
} else {
var popupSize = computePopupSize(dropdownBox, overlayBox, constraints);
return getPosition(dropdownBox, overlayBox, popupSize, align)
.addMargin(margin);
}
}