BarHoverCallback typedef

BarHoverCallback = void Function(ChartDataPoint? point, int? datasetIndex, int? barIndex)

Callback for mouse hover events on bars.

Invoked when the mouse enters or exits a bar area in bar charts. When the mouse exits, all parameters will be null.

Supported Charts:

  • Bar charts (BarChartWidget)
  • Stacked column charts (StackedColumnChartWidget)

Parameters:

  • point - The data point for the hovered bar, or null if mouse exited
  • datasetIndex - The dataset index, or null if mouse exited
  • barIndex - The bar index, or null if mouse exited

Usage Notes:

  • This callback is nullable - if null, hover interactions are disabled
  • Platform Support: Desktop and web only (mouse hover not available on mobile)
  • All parameters are nullable - check for null to detect mouse exit

Example

onBarHover: (point, datasetIndex, barIndex) {
  if (point != null) {
    highlightBar(barIndex);
  }
}

See also:

Implementation

typedef BarHoverCallback =
    void Function(ChartDataPoint? point, int? datasetIndex, int? barIndex);