performRebuild method

  1. @override
void performRebuild()
override

Rebuilds this element's subtree from its current widget configuration.

Implementation

@override
void performRebuild() {
  if (children.isEmpty) {
    _child = _widget.child.createElement();
    children.add(_child);
    _child.mount(this, owner);
  } else {
    final currentChild = children.first;
    if (Widget.canUpdate(currentChild.widget, _widget.child)) {
      _child = currentChild;
      _child.update(_widget.child);
      return;
    }

    currentChild.unmount();
    _child = _widget.child.createElement();
    children
      ..clear()
      ..add(_child);
    _child.mount(this, owner);
  }
}