detachRenderBox static method

void detachRenderBox(
  1. RenderObject renderBox
)

Implementation

static void detachRenderBox(RenderObject renderBox) {
  if (renderBox.parent == null) return;

  // Remove reference from parent.
  RenderObject? parentRenderObject = renderBox.parent as RenderObject;
  if (parentRenderObject is RenderObjectWithChildMixin) {
    parentRenderObject.child = null; // Case for single child, eg. RenderViewportBox.
  } else if (parentRenderObject is ContainerRenderObjectMixin) {
    parentRenderObject.remove(renderBox); // Case for multi children, eg. RenderLayoutBox or RenderSliverList.
  }
}