createRenderer method Null safety

StackedLineSeriesRenderer createRenderer(
  1. ChartSeries<T, D> series

to create a Stacked line series renderer


StackedLineSeriesRenderer createRenderer(ChartSeries<T, D> series) {
  StackedLineSeriesRenderer stackedLineSeriesRenderer;
  if (onCreateRenderer != null) {
    stackedLineSeriesRenderer =
        onCreateRenderer!(series) as StackedLineSeriesRenderer;
    // ignore: unnecessary_null_comparison
    assert(stackedLineSeriesRenderer != null,
        'This onCreateRenderer callback function should return value as extends from ChartSeriesRenderer class and should not be return value as null');
    return stackedLineSeriesRenderer;
  return StackedLineSeriesRenderer();