updateChild method

Element? updateChild(
  1. Element? child,
  2. Widget newWidget
)

Updates the given child to use the given newWidget, returning the updated or newly created child element.

Implementation

Element? updateChild(Element? child, Widget newWidget) {
  if (child != null && Widget.canUpdate(child.widget, newWidget)) {
    child.update(newWidget);
    return child;
  }
  if (child != null) {
    child.unmount();
  }
  final newChild = newWidget.createElement();
  newChild.mount(this);
  return newChild;
}