topMostYtoTarget static method

double topMostYtoTarget({
  1. required double? top,
  2. required double? bottom,
  3. required double margin,
  4. required Offset target,
  5. required Size size,
  6. required Size childSize,
})

Implementation

static double topMostYtoTarget({
  required double? top,
  required double? bottom,
  required double margin,
  required Offset target,
  required Size size,
  required Size childSize,
}) {
  double topmostYtoTarget;

  if (top != null) {
    topmostYtoTarget = top;
  } else if (bottom != null) {
    topmostYtoTarget = max(
      size.topLeft(Offset.zero).dy + margin,
      size.bottomRight(Offset.zero).dy - margin - childSize.height - bottom,
    );
  } else {
    topmostYtoTarget = max(
      margin,
      min(
        target.dy - childSize.height / 2,
        size.bottomRight(Offset.zero).dy - margin - childSize.height,
      ),
    );
  }

  return topmostYtoTarget;
}