PieSegmentHoverCallback typedef

PieSegmentHoverCallback = void Function(PieData? segment, int? segmentIndex)

Callback for mouse hover events on pie chart segments.

Invoked when the mouse enters or exits a segment area in pie/donut charts. When the mouse exits, all parameters will be null.

Supported Charts:

  • Pie charts (PieChartWidget)
  • Donut charts (DonutChartWidget)
  • Pyramid charts (PyramidChartWidget)
  • Funnel charts (FunnelChartWidget)

Parameters:

  • segment - The hovered segment, or null if mouse exited
  • segmentIndex - The segment 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

onSegmentHover: (segment, segmentIndex) {
  if (segment != null) {
    showTooltip('${segment.label}: ${segment.value}');
  }
}

See also:

Implementation

typedef PieSegmentHoverCallback =
    void Function(PieData? segment, int? segmentIndex);