getPositionForChild method Null safety
override
The position where the child should be placed.
The size
argument is the size of the parent, which might be different
from the value returned by getSize if that size doesn't satisfy the
constraints passed to getSize. The childSize
argument is the size of
the child, which will satisfy the constraints returned by
getConstraintsForChild.
Defaults to positioning the child in the upper left corner of the parent.
Implementation
@override
Offset getPositionForChild(Size size, Size childSize) {
final Offset overhang = Offset(
anchor.dx + childSize.width - size.width,
anchor.dy + childSize.height - size.height,
);
return Offset(
overhang.dx > 0.0 ? anchor.dx - overhang.dx : anchor.dx,
overhang.dy > 0.0 ? anchor.dy - overhang.dy : anchor.dy,
);
}