rebuild method

void rebuild()

Cause the component to update itself.

Called by the BuildOwner when rebuilding, by mount when the element is first built, and by update when the component has changed.

Implementation

void rebuild() {
  assert(_lifecycleState != _ElementLifecycle.initial);
  if (_lifecycleState != _ElementLifecycle.active || !_dirty) {
    return;
  }
  assert(_lifecycleState == _ElementLifecycle.active);
  assert(owner._debugStateLocked);
  assert(() {
    if (!binding.isClient && owner.isFirstBuild) return true;
    _debugPreviousBuildTarget = owner._debugCurrentBuildTarget;
    owner._debugCurrentBuildTarget = this;
    return true;
  }());
  if (_observerElements != null && _observerElements!.isNotEmpty) {
    for (final observer in _observerElements!) {
      observer.willRebuildElement(this);
    }
  }
  owner.performRebuildOn(this);
}