dataLabelMapper property Null safety

ChartIndexedValueMapper<String>? dataLabelMapper
final

Field in the data source, which is considered as text for the data points.

Defaults to null.

Widget build(BuildContext context) {
  return SfCartesianChart(
    series: <BarSeries<SalesData, num>>[
      BarSeries<SalesData, num>(
        dataSource: <SalesData>[
          SalesData(DateTime(2005, 0, 1), 'India', 16),
          SalesData(DateTime(2006, 0, 1), 'China', 12),
          SalesData(DateTime(2007, 0, 1), 'USA',18),
        ],
        dataLabelSettings: DataLabelSettings(isVisible:true),
        dataLabelMapper: (SalesData data, _) => data.category,
      ),
    ],
  );
}
class SalesData {
  SalesData(this.year, this.category, this.sales1);
    final DateTime year;
    final String category;
    final int sales1;
}

Implementation

@override
final ChartIndexedValueMapper<String>? dataLabelMapper;