calculateBeaconPosition static method

Offset calculateBeaconPosition(
  1. String position,
  2. Offset widgetPosition,
  3. Size widgetSize
)

Implementation

static Offset calculateBeaconPosition(
    String position, Offset widgetPosition, Size widgetSize) {
  double val = 15; //30 should be half of raius of circle
  switch (position) {
    case "topleft":
      return widgetPosition - Offset(val, val); // Adjusted for padding
    case "topright":
      return Offset(widgetPosition.dx + widgetSize.width - val,
          widgetPosition.dy - val);
    case "bottomleft":
      return Offset(widgetPosition.dx - val,
          widgetPosition.dy + widgetSize.height - val);
    case "bottomright":
      return Offset(widgetPosition.dx + widgetSize.width - val,
          widgetPosition.dy + widgetSize.height - val);
    case "center":
      return Offset(widgetPosition.dx + widgetSize.width / 2 - val,
          widgetPosition.dy + widgetSize.height / 2 - val);
    case "topcenter":
    case "top":
      return Offset(widgetPosition.dx + widgetSize.width / 2 - val,
          widgetPosition.dy - val);
    case "bottomcenter":
    case "bottom":
      return Offset(widgetPosition.dx + widgetSize.width / 2 - val,
          widgetPosition.dy + widgetSize.height - val);
    case "leftcenter":
    case "left":
      return Offset(widgetPosition.dx - val,
          widgetPosition.dy + widgetSize.height / 2 - val);
    case "rightcenter":
    case "right":
      return Offset(widgetPosition.dx + widgetSize.width - val,
          widgetPosition.dy + widgetSize.height / 2 - val);
    default:
      return widgetPosition;
  }
}