build method

  1. @override
Widget build()
override

Subclasses should override this function to actually call the appropriate build function (e.g., StatelessWidget.build or State.build) for their widget.

Implementation

@override
Widget build() {
  Widget? built;

  reaction.track(() {
    built = super.build();
  });

  if (enableWarnWhenNoObservables &&
      (_widget.warnWhenNoObservables ?? true) &&
      !reaction.hasObservables) {
    _widget.log(
      'No observables detected in the build method of ${reaction.name}',
    );
  }

  // This "throw" is better than a "LateInitializationError"
  // which confused the user. Please see #780 for details.
  if (built == null) {
    throw Exception(
        'Error happened when building ${_widget.runtimeType}, but it was captured since disableErrorBoundaries==true');
  }

  return built!;
}