updateChild method

RenderObject? updateChild(
  1. RenderObject? current,
  2. RenderObject? next
)

Drop current and adopt next, returning next as the new child.

Idempotent: when current and next are identical the child is left untouched. Otherwise the old child is dropped (if owned) and the new child is adopted (if not already owned).

Implementation

RenderObject? updateChild(RenderObject? current, RenderObject? next) {
  if (identical(current, next)) return current;
  if (current != null && current.parent == this) dropChild(current);
  if (next != null && next.parent != this) adoptChild(next);
  return next;
}