performBoxLayout method

  1. @override
void performBoxLayout(
  1. BoxConstraints constraints
)
override

Perform layout with typed box constraints

Subclasses override this instead of performLayout. The default implementation sizes to the maxima, treating an unbounded axis as the corresponding lower bound.

Implementation

@override
void performBoxLayout(BoxConstraints constraints) {
  if (_child != null) {
    // Layout child with same constraints
    _child!.layout(constraints);

    // Position child at origin
    positionChild(_child!, 0, 0);

    // Size to child
    size = Size(
      constraints.constrainWidth(_child!.width),
      constraints.constrainHeight(_child!.height),
    );
  } else {
    // No child, size to smallest possible within constraints
    size = Size(
      constraints.constrainWidth(0),
      constraints.constrainHeight(0),
    );
  }
}