ChartInteractionResult class

Result of a chart interaction.

This immutable class represents the result of detecting a tap or hover on a chart element. It contains information about which element was interacted with and its position.

Use isHit to check if an interaction was successful. If isHit is true, then either point (for point-based charts) or segment (for pie charts) will be non-null, along with the corresponding indices.

Example

final result = ChartInteractionHelper.findNearestPoint(...);
if (result != null && result.isHit) {
  print('Hit point: ${result.point!.y} at index ${result.elementIndex}');
}

See also:

  • ChartInteractionHelper for finding interactions (import from utils)
  • ChartInteractionConstants for interaction configuration

Constructors

ChartInteractionResult({ChartDataPoint? point, PieData? segment, int? datasetIndex, int? elementIndex, bool isHit = false})
Creates a chart interaction result.
const
ChartInteractionResult.none()
Creates a result representing no interaction.
const

Properties

datasetIndex int?
The index of the dataset containing the interacted element.
final
elementIndex int?
The index of the element within its dataset or data list.
final
hashCode int
The hash code for this object.
no setteroverride
isHit bool
Whether an interaction was successfully detected.
final
point ChartDataPoint?
The data point that was interacted with, if applicable.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
segment PieData?
The pie segment that was interacted with, if applicable.
final

Methods

copyWith({ChartDataPoint? point, PieData? segment, int? datasetIndex, int? elementIndex, bool? isHit}) ChartInteractionResult
Creates a copy of this result with the given fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override