performLayout method

  1. @override
void performLayout(
  1. Constraints constraints
)
override

Called to perform the actual layout computation for this render object.

Implementation

@override
void performLayout(Constraints constraints) {
  final boxConstraints = BoxConstraints.asBox(constraints);
  final childWidget = builder(buildContext, boxConstraints);

  if (!identical(childWidget, _cachedWidget)) {
    _childElement?.unmount();
    _childElement = childWidget.createElement()..mount(null);
    _cachedWidget = childWidget;
  }

  final childRender = _childElement?.renderObject;
  if (childRender != null) {
    childRender.layout(constraints, parentUsesSize: true);
    size = childRender.size ?? Size.zero;
    child = childRender as RenderBox;
  } else {
    size = Size.zero;
    child = null;
  }
}