attachRenderBox static method

void attachRenderBox(
  1. RenderObject parentRenderObject,
  2. RenderBox renderBox, {
  3. RenderObject? after,
  4. bool isLast = false,
})

Implementation

static void attachRenderBox(
  RenderObject parentRenderObject,
  RenderBox renderBox,
  {RenderObject? after, bool isLast = false}
  ) {
  if (isLast) {
    assert(after == null);
  }
  if (parentRenderObject is RenderObjectWithChildMixin) { // RenderViewportBox
    parentRenderObject.child = renderBox;
  } else if (parentRenderObject is ContainerRenderObjectMixin) { // RenderLayoutBox or RenderSliverList
    // Should attach to renderScrollingContent if it is scrollable.
    if (parentRenderObject is RenderLayoutBox) {
      parentRenderObject = parentRenderObject.renderScrollingContent ?? parentRenderObject;
    }
    if (isLast) {
      after = parentRenderObject.lastChild;
    }
    parentRenderObject.insert(renderBox, after: after);
  }
}