offsetFromRect method

Offset offsetFromRect(
  1. Rect rect,
  2. double fontSize,
  3. double margin
)

Calculates display offset from rect including margin.

Implementation

Offset offsetFromRect(Rect rect, double fontSize, double margin) {
  switch (this) {
    case DetectionLabelPosition.topLeft:
    case DetectionLabelPosition.topRight:
    case DetectionLabelPosition.topCenter:
      return Offset(rect.left, rect.top - fontSize - margin);
    case DetectionLabelPosition.bottomLeft:
    case DetectionLabelPosition.bottomRight:
    case DetectionLabelPosition.bottomCenter:
      return Offset(rect.left, rect.bottom + margin);
  }
}