getHighlight method
Implementation
@override
Highlight? getHighlight(double x, double y) {
double touchDistanceToCenter = _painter!.distanceToCenter(x, y);
// check if a slice was touched
if (touchDistanceToCenter > _painter!.getRadius()) {
// if no slice was touched, highlight nothing
return null;
} else {
double angle = _painter!.getAngleForPoint(x, y);
if (_painter is PieChartPainter) {
angle /= _painter!.animator!.getPhaseY();
}
int index = _painter!.getIndexForAngle(angle);
// check if the index could be found
if (index < 0 ||
index >=
_painter!.getData()!.getMaxEntryCountSet()!.getEntryCount()) {
return null;
} else {
return getClosestHighlight(index, x, y);
}
}
}