PieSegmentCallback typedef

PieSegmentCallback = void Function(PieData segment, int segmentIndex, Offset position)

Callback for pie chart segment tap interactions.

Invoked when a user taps on a segment in pie/donut charts.

Supported Charts:

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

Parameters:

  • segment - The tapped pie segment (never null)
  • segmentIndex - The index of the segment in the data list (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

onSegmentTap: (segment, segmentIndex, position) {
  print('Tapped segment: ${segment.label} (${segment.value})');
}

See also:

Implementation

typedef PieSegmentCallback =
    void Function(PieData segment, int segmentIndex, Offset position);