performLayout method

  1. @override
void performLayout()
override

Do layout

Implementation

@override
void performLayout() {
  List<Rect> childrenLocations = _layoutChildren(
    constraints.maxWidth,
    constraints.maxHeight,
  );

  double height = 0;
  double width = 0;

  var child = firstChild;

  for (int i = 0; i < childrenLocations.length; i++) {
    height = max(height, childrenLocations.elementAt(i).bottom);
    width = max(width, childrenLocations.elementAt(i).right);

    // Do actual layout
    child!.layout(
      BoxConstraints(
        maxWidth: childrenLocations.elementAt(i).width,
        maxHeight: childrenLocations.elementAt(i).height,
        minWidth: 0,
        minHeight: 0,
      ),
      parentUsesSize: true,
    );

    WrapParentData childParentData = child.parentData as WrapParentData;
    child = childParentData.nextSibling;
  }

  size = Size(width, height);
}