performRebuild method

  1. @override
void performRebuild ()
override

Calls the StatelessWidget.build method of the StatelessWidget object (for stateless widgets) or the State.build method of the State object (for stateful widgets) and then updates the widget tree.

Called automatically during mount to generate the first build, and by rebuild when the element needs updating.

Implementation

@override
void performRebuild() {
  assert(() {
    if (debugProfileBuildsEnabled)
      Timeline.startSync('${widget.runtimeType}',  arguments: timelineWhitelistArguments);
    return true;
  }());

  assert(_debugSetAllowIgnoredCallsToMarkNeedsBuild(true));
  Widget built;
  try {
    built = build();
    debugWidgetBuilderValue(widget, built);
  } catch (e, stack) {
    built = ErrorWidget.builder(_debugReportException('building $this', e, stack));
  } finally {
    // We delay marking the element as clean until after calling build() so
    // that attempts to markNeedsBuild() during build() will be ignored.
    _dirty = false;
    assert(_debugSetAllowIgnoredCallsToMarkNeedsBuild(false));
  }
  try {
    _child = updateChild(_child, built, slot);
    assert(_child != null);
  } catch (e, stack) {
    built = ErrorWidget.builder(_debugReportException('building $this', e, stack));
    _child = updateChild(null, built, slot);
  }

  assert(() {
    if (debugProfileBuildsEnabled)
      Timeline.finishSync();
    return true;
  }());
}