onLegendTapped property

ChartLegendTapCallback? onLegendTapped
final

Occurs when the legend item is rendered. Here, you can get the legend’s text, shape, series index, and point index of circular series.

Widget build(BuildContext context) {
   return Container(
       child: SfCartesianChart(
           onLegendTapped: (LegendTapArgs args) => legend(args),
       ));
}
void legend(LegendTapArgs args) {
  print(args.pointIndex);
}

Implementation

final ChartLegendTapCallback? onLegendTapped;