dataSource property Null safety

List<T> dataSource
final

Data required for rendering the series.

If no data source is specified, empty chart will be rendered without series.

Defaults to null.

Widget build(BuildContext context) {
   return Container(
       child: SfCartesianChart(
           series: <ColumnSeries<SalesData, num>>[
               ColumnSeries<SalesData, num>(
                 dataSource: chartData,
                 xValueMapper: (SalesData sales, _) => sales.x,
                 yValueMapper: (SalesData sales, _) => sales.y,
               ),
             ],
       ));
}
final List<SalesData> chartData = <SalesData>[
   SalesData(1, 23),
   SalesData(2, 35),
   SalesData(3, 19)
 ];

class SalesData {
  SalesData(this.x, this.y);
  final double x;
  final double y;
}

Implementation

@override
final List<T> dataSource;