ChartPointCallback typedef
ChartPointCallback =
void Function(ChartDataPoint point, int datasetIndex, int pointIndex, Offset position)
Callback for chart point tap interactions.
Invoked when a user taps on a data point in point-based charts.
Supported Charts:
- Line charts (
LineChartWidget) - Area charts (
AreaChartWidget) - Scatter charts (
ScatterChartWidget) - Bubble charts (
BubbleChartWidget) - useonBubbleTap - Stacked area charts (
StackedAreaChartWidget) - Step line charts (
StepLineChartWidget) - Spline charts (
SplineChartWidget) - Sparkline charts (
SparklineChartWidget)
Parameters:
point- The tapped data point (never null)datasetIndex- The index of the dataset containing this point (never null)pointIndex- The index of the point within its dataset (never null)position- The global tap position (useful for showing context menus)
Usage Notes:
- This callback is nullable - if null, tap interactions are disabled
- Haptic feedback is automatically provided on mobile platforms
- The tap detection uses ChartInteractionConstants.tapRadius for hit detection
Example
onPointTap: (point, datasetIndex, pointIndex, position) {
print('Tapped point: ${point.y} at ($datasetIndex, $pointIndex)');
showContextMenu(position);
}
See also:
ChartPointHoverCallbackfor hover events (desktop/web only)onBubbleTapfor bubble chart-specific tap handlingChartInteractionConstantsfor interaction configuration
Implementation
typedef ChartPointCallback =
void Function(
ChartDataPoint point,
int datasetIndex,
int pointIndex,
Offset position,
);