shouldRepaint method

  1. @override
bool shouldRepaint(
  1. ChartData? oldDelegate
)
override

Checks if this ChartData needs to repaint with the chart widget's new frame.

Implementation

@override
// ignore: avoid_renaming_method_parameters
bool shouldRepaint(ChartData? oldDelegate) {
  final DataSeries<T> oldDataSeries = oldDelegate as DataSeries<T>;
  final VisibleEntries<Tick> current = visibleEntries;
  final VisibleEntries<Tick> previous = oldDataSeries.visibleEntries;

  if (current.isEmpty && previous.isEmpty) {
    return false;
  }
  if (current.isEmpty != previous.isEmpty) {
    return true;
  }

  return current.first != previous.first ||
      current.last != previous.last ||
      style != oldDataSeries.style ||
      ((entries?.isNotEmpty ?? false) &&
          visibleEntries.isNotEmpty &&
          entries?.last == visibleEntries.last);
}