leftMostXtoTarget static method
Implementation
static double leftMostXtoTarget({
required double? left,
required double? right,
required double margin,
required Size size,
required Size childSize,
required Offset target,
}) {
double leftMostXtoTarget;
if (left != null) {
leftMostXtoTarget = left;
} else if (right != null) {
// leftMostXtoTarget
// ________________________
// | |
// | childSize.width |
// ________________________
//
// topLeft -> | | | | <- topRight
// | | | |
// | | | |
// ^ ^
// margin margin
leftMostXtoTarget = max(
size.topLeft(Offset.zero).dx + margin,
size.topRight(Offset.zero).dx - margin - childSize.width - right,
);
} else {
leftMostXtoTarget = max(
margin,
min(
target.dx - childSize.width / 2,
size.topRight(Offset.zero).dx - margin - childSize.width,
),
);
}
return leftMostXtoTarget;
}