detach method

  1. @override
void detach()
inherited

Detach renderObject from parent.

Implementation

@override
void detach() {
  RenderBoxModel? selfRenderBoxModel = renderBoxModel;
  if (selfRenderBoxModel == null) return;

  willDetachRenderer();

  // Remove fixed children from root when dispose
  _removeFixedChild(selfRenderBoxModel);

  RenderObject? parent = selfRenderBoxModel.parent as RenderObject?;
  if (parent is ContainerRenderObjectMixin) {
    parent.remove(selfRenderBoxModel);
  } else if (parent is RenderProxyBox) {
    parent.child = null;
  }

  for (Node child in childNodes) {
    child.detach();
  }

  didDetachRenderer();

  // Call dispose method of renderBoxModel when it is detached from tree
  selfRenderBoxModel.dispose();
  renderBoxModel = null;
}