attachTo method

  1. @override
void attachTo(
  1. Node parent, {
  2. RenderBox? after,
})
inherited

Attach a renderObject to parent.

Implementation

@override
void attachTo(Node parent, {RenderBox? after}) {
  _applyStyle(style);

  if (parentElement?.renderStyle.display == CSSDisplay.sliver) {
    // Sliver should not create renderer here, but need to trigger
    // render sliver list dynamical rebuild child by element tree.
    parentElement?._renderLayoutBox?.markNeedsLayout();
  } else {
    willAttachRenderer();
  }

  if (renderer != null) {
    // If element attach WidgetElement, render object should be attach to render tree when mount.
    if (parent is! WidgetElement) {
      RenderBoxModel.attachRenderBox(parent.renderer!, renderer!, after: after);
    }

    // Flush pending style before child attached.
    style.flushPendingProperties();

    didAttachRenderer();
  }
}