ChartTapCallback typedef
ChartTapCallback =
void Function(Offset position)
Callback for chart background/empty area tap interactions.
Invoked when a user taps on an empty area of the chart (not on any data element). Useful for deselecting items, closing menus, or resetting chart state.
Supported Charts:
- All chart types support this callback
Parameters:
position- The global tap position where the user tapped
Usage Notes:
- This callback is nullable - if null, background taps are ignored
- Only fires when tapping on empty chart area (not on data points, bars, segments, etc.)
- Useful for implementing "tap to deselect" or "tap to close menu" behavior
Example
onChartTap: (position) {
// Deselect all items
setState(() {
selectedItem = null;
});
// Close any open menus
ChartContextMenuHelper.hide();
}
See also:
- ChartPointCallback for point tap events
- PieSegmentCallback for segment tap events
- BarCallback for bar tap events
Implementation
typedef ChartTapCallback = void Function(Offset position);