updateSlotForChild method

  1. @protected
void updateSlotForChild(
  1. Element child,
  2. ElementSlot newSlot
)

Change the slot that the given child occupies in its parent.

Called by MultiChildRenderObjectElement, and other RenderObjectElement subclasses that have multiple children, when child moves from one position to another in this element's child list.

Implementation

@protected
void updateSlotForChild(Element child, ElementSlot newSlot) {
  assert(_lifecycleState == _ElementLifecycle.active);
  assert(child._parent == this);
  void visit(Element element) {
    element.updateSlot(newSlot);
    if (element is! RenderObjectElement) {
      Element? next;
      element.visitChildren((Element child) {
        assert(next == null); // This verifies that there's only one child.
        next = child;
        visit(child);
      });
    }
  }

  visit(child);
}