updateChild method

  1. @protected
Element? updateChild(
  1. Element? child,
  2. Widget? newWidget,
  3. Object? newSlot
)
inherited

Makes child show newWidget at newSlot and returns the element that does: child itself when the widget is the same or matches it, else a new element in its place. A null newWidget removes child.

Implementation

@protected
Element? updateChild(Element? child, Widget? newWidget, Object? newSlot) {
  if (newWidget == null) {
    if (child != null) {
      deactivateChild(child);
    }
    return null;
  }
  if (child == null) {
    return inflateWidget(newWidget, newSlot);
  }
  if (Widget.canUpdate(child.widget, newWidget)) {
    if (child.slot != newSlot) {
      updateSlotForChild(child, newSlot);
    }
    if (!identical(child.widget, newWidget)) {
      child.update(newWidget);
    }
    return child;
  }
  deactivateChild(child);
  return inflateWidget(newWidget, newSlot);
}