BarCallback typedef
BarCallback =
void Function(ChartDataPoint point, int datasetIndex, int barIndex, Offset position)
Callback for bar chart tap interactions.
Invoked when a user taps on a bar in a bar chart.
Supported Charts:
- Bar charts (
BarChartWidget) - Stacked column charts (
StackedColumnChartWidget)
Parameters:
point- The data point represented by this bar (never null)datasetIndex- The index of the dataset containing this bar (never null)barIndex- The index of the bar 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
Example
onBarTap: (point, datasetIndex, barIndex, position) {
print('Tapped bar: ${point.y}');
}
See also:
- BarHoverCallback for hover events (desktop/web only)
Implementation
typedef BarCallback =
void Function(
ChartDataPoint point,
int datasetIndex,
int barIndex,
Offset position,
);