build method Null safety

  1. @override
Widget build(
  1. BuildContext context
)
override

Describes the part of the user interface represented by this widget.

The framework calls this method in a number of different situations. For example:

Here it is called whenever the user interaction is performed and it removes the old widget and updates a chart with a new widget in SfCircularChart.

Implementation

@override
Widget build(BuildContext context) {
  _stateProperties.renderingDetails.initialRender =
      (_stateProperties.renderingDetails.widgetNeedUpdate &&
              !_stateProperties.renderingDetails.isLegendToggled)
          ? _stateProperties.needExplodeAll
          : (_stateProperties.renderingDetails.initialRender == null);
  _stateProperties.renderingDetails.oldDeviceOrientation =
      _stateProperties.renderingDetails.oldDeviceOrientation == null
          ? MediaQuery.of(context).orientation
          : _stateProperties.renderingDetails.deviceOrientation;
  _stateProperties.renderingDetails.deviceOrientation =
      MediaQuery.of(context).orientation;
  _stateProperties.isTooltipOrientationChanged = false;

  final Widget container = ChartContainer(
    child: GestureDetector(
        child: Container(
      decoration: BoxDecoration(
          color: widget.backgroundColor ??
              _stateProperties
                  .renderingDetails.chartTheme.plotAreaBackgroundColor,
          image: widget.backgroundImage != null
              ? DecorationImage(
                  image: widget.backgroundImage!, fit: BoxFit.fill)
              : null,
          border: Border.all(
              color: widget.borderColor, width: widget.borderWidth)),
      child: Column(
        children: <Widget>[
          renderChartTitle(_stateProperties),
          _renderChartElements()
        ],
      ),
    )),
  );
  return RepaintBoundary(child: container);
}