getMenuOffset function
Offset
getMenuOffset(
- PopupDirection direction,
- double fabSize,
- double horizontalMargin,
- double verticalMargin,
Helper: compute the offset for the popup relative to the FAB’s top-left corner.
Implementation
Offset getMenuOffset(
PopupDirection direction,
double fabSize,
double horizontalMargin,
double verticalMargin,
double menuWidth,
double menuHeight,
) {
switch (direction) {
case PopupDirection.top:
return Offset((fabSize - menuWidth) / 2, -menuHeight - verticalMargin);
case PopupDirection.bottom:
return Offset((fabSize - menuWidth) / 2, fabSize + verticalMargin);
case PopupDirection.left:
return Offset(-menuWidth - horizontalMargin, (fabSize - menuHeight) / 2);
case PopupDirection.right:
return Offset(fabSize + horizontalMargin, (fabSize - menuHeight) / 2);
case PopupDirection.topLeft:
return Offset(-menuWidth - horizontalMargin, -menuHeight - verticalMargin);
case PopupDirection.topRight:
return Offset(fabSize + horizontalMargin, -menuHeight - verticalMargin);
case PopupDirection.bottomLeft:
return Offset(-menuWidth - horizontalMargin, fabSize + verticalMargin);
case PopupDirection.bottomRight:
return Offset(fabSize + horizontalMargin, fabSize + verticalMargin);
}
}