performLayout method

  1. @override
Size performLayout(
  1. BoxConstraints constraints
)
override

Hook for subclasses to perform layout within the given constraints.

Implementation

@override
Size performLayout(BoxConstraints constraints) {
  final builderWidget = widget as LayoutBuilder;

  // 1. Build Phase: Invoke builder callback using incoming constraints
  final childWidget = builderWidget.builder(this, constraints);

  // 2. Reconciliation Phase: Mount or update child element
  if (_child != null &&
      _child!.widget.runtimeType == childWidget.runtimeType) {
    _child!.update(childWidget);
  } else {
    _child?.unmount();
    _child = childWidget.createElement();
    _child!.mount(this);
  }

  // 3. Child Layout Phase: Run layout recursively on the child element tree
  final childSize = _child!.layout(constraints);
  return childSize;
}