layoutPositionedChild static method

void layoutPositionedChild(
  1. RenderBoxModel parent,
  2. RenderBoxModel child, {
  3. bool needsRelayout = false,
})

Implementation

static void layoutPositionedChild(
  RenderBoxModel parent,
  RenderBoxModel child,
  {bool needsRelayout = false}
) {
  BoxConstraints childConstraints = child.getConstraints();

  // Whether child need to layout
  bool isChildNeedsLayout = true;
  if (child.hasSize &&
    !needsRelayout &&
    (childConstraints == child.constraints) &&
    (!child.needsLayout)
  ) {
    isChildNeedsLayout = false;
  }

  if (isChildNeedsLayout) {
    late DateTime childLayoutStartTime;
    if (kProfileMode) {
      childLayoutStartTime = DateTime.now();
    }

    // Should create relayoutBoundary for positioned child.
    child.layout(childConstraints, parentUsesSize: false);

    if (kProfileMode) {
      DateTime childLayoutEndTime = DateTime.now();
      parent.childLayoutDuration += (childLayoutEndTime.microsecondsSinceEpoch - childLayoutStartTime.microsecondsSinceEpoch);
    }
  }
}