getCustomPosition static method
CustomTargetContentPosition
getCustomPosition(
- String position,
- GlobalKey<
State< keyTargetStatefulWidget> >
Implementation
static CustomTargetContentPosition getCustomPosition(
String position,
GlobalKey keyTarget,
) {
const double verticalOffset = 220;
const double horizontalOffset = 50;
final RenderBox renderBox =
keyTarget.currentContext!.findRenderObject() as RenderBox;
final Offset widgetPos = renderBox.localToGlobal(Offset.zero);
// final Size widgetSize = renderBox.size;
switch (position) {
case "center":
return CustomTargetContentPosition(
top: widgetPos.dy - (verticalOffset - 100),
);
case "topLeft":
return CustomTargetContentPosition(
top: widgetPos.dy - verticalOffset,
right: widgetPos.dx - horizontalOffset,
);
case "topRight":
return CustomTargetContentPosition(
top: widgetPos.dy - verticalOffset,
left: widgetPos.dx - horizontalOffset,
);
case "bottomLeft":
return CustomTargetContentPosition(
bottom: widgetPos.dy - verticalOffset,
right: widgetPos.dx - horizontalOffset,
);
case "bottomRight":
return CustomTargetContentPosition(
bottom: widgetPos.dy - verticalOffset,
left: widgetPos.dx - horizontalOffset,
);
default:
return CustomTargetContentPosition(
top: 0,
);
}
}