attachRenderObject method Null safety

  1. @override
void attachRenderObject(
  1. Object? newSlot
)
override

Add renderObject to the render tree at the location specified by newSlot.

The default implementation of this function simply calls attachRenderObject recursively on each child. The RenderObjectElement.attachRenderObject override does the actual work of adding renderObject to the render tree.

The newSlot argument specifies the new value for this element's slot.

Implementation

@override
void attachRenderObject(Object? newSlot) {
  assert(_ancestorRenderObjectElement == null);
  _slot = newSlot;
  _ancestorRenderObjectElement = _findAncestorRenderObjectElement();
  _ancestorRenderObjectElement?.insertRenderObjectChild(renderObject, newSlot);
  final ParentDataElement<ParentData>? parentDataElement = _findAncestorParentDataElement();
  if (parentDataElement != null)
    _updateParentData(parentDataElement.widget);
}