google / charts

https://pub.dev/packages/charts_flutter
Apache License 2.0
2.81k stars 1.2k forks source link

"Null check operator used on a null value" on legend with measures #786

Open LamsaLL opened 2 years ago

LamsaLL commented 2 years ago

When we set legendDefaultMesaure different than none and we want to toggle show\hide series on legend we got this error : bar-chart-on-tap bug-hide-series-on-legend

Here is the code of my graph :

class GroupedBarChart extends StatelessWidget {
  final List<charts.Series<dynamic, String>> seriesList;

  const GroupedBarChart({Key? key, required this.seriesList}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return charts.BarChart(seriesList,
        animate: true,
        barGroupingType: charts.BarGroupingType.grouped,
        behaviors: [
          charts.SeriesLegend(
              position: charts.BehaviorPosition.top,
              horizontalFirst: true,
              cellPadding: const EdgeInsets.only(right: 16),
              showMeasures: true,
              legendDefaultMeasure: charts.LegendDefaultMeasure.sum,
              measureFormatter: (num? value) {
                return value == null ? '-' : value.round().toString();
              }),
        ]);
  }
}
heshaShawky commented 1 year ago

did you get to fix it?