layoutRect method
Lays out and positions the child so that it fits in rect.
If the alignment argument is provided, the child is loosely constrained
and aligned into rect, otherwise it is tightly constrained.
See also:
- layout, which lays out the child given raw BoxConstraints.
- layoutFit, which positions and scales the child given a BoxFit.
Implementation
void layoutRect(Rect rect, {Alignment? alignment, bool useSize = true}) {
if (alignment != null) {
final size = layout(BoxConstraints.loose(rect.size));
position(alignment.inscribe(size, rect).topLeft);
} else {
layoutWithoutSize(BoxConstraints.tight(rect.size), useSize: useSize);
position(rect.topLeft);
}
}