unmountRenderObject method

  1. @override
void unmountRenderObject({
  1. bool deep = true,
  2. bool keepFixedAlive = false,
  3. bool dispose = true,
  4. bool fromFlutterWidget = false,
})
override

Unmount renderBoxModel.

Implementation

@override
void unmountRenderObject(
    {bool deep = true, bool keepFixedAlive = false, bool dispose = true, bool fromFlutterWidget = false}) {
  /// If a node is managed by flutter framework, the ownership of this render object will transferred to Flutter framework.
  /// So we do nothing here.
  if (!fromFlutterWidget && managedByFlutterWidget) {
    return;
  }

  // Ignore the fixed element to unmount render object.
  // It's useful for sliver manager to unmount child render object, but excluding fixed elements.
  if (keepFixedAlive && renderStyle.position == CSSPositionType.fixed) {
    return;
  }

  willDetachRenderer();

  // Dispose all renderObject when deep.
  if (deep) {
    for (Node child in [...childNodes]) {
      child.unmountRenderObject(deep: deep, keepFixedAlive: keepFixedAlive);
    }
  }

  didDetachRenderer();
  if (dispose) {
    // RenderObjects could be owned by Flutter Widget Frameworks.
    if (!isRenderObjectOwnedByFlutterFramework(this)) {
      ownerDocument.inactiveRenderObjects.add(renderer);
    }
  }

  renderBoxModel = null;
}