updateChild method
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;
}