layoutRect method

void layoutRect(
  1. Rect rect, {
  2. Alignment? alignment,
  3. bool useSize = true,
})

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:

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);
  }
}