contains method

  1. @override
bool contains(
  1. Offset position
)
override

Implementation

@override
bool contains(Offset position) {
  if (points.isEmpty) {
    return false;
  }

  late Rect segmentBounds;
  if (series.isTransposed) {
    final Offset start = series.yAxis != null && series.yAxis!.isInversed
        ? points[0]
        : points[1];
    final Offset end = series.yAxis != null && series.yAxis!.isInversed
        ? points[1]
        : points[0];
    segmentBounds = Rect.fromLTRB(
        start.dx, start.dy - hiloPadding, end.dx, end.dy + hiloPadding);
  } else {
    final Offset start = series.yAxis != null && series.yAxis!.isInversed
        ? points[1]
        : points[0];
    final Offset end = series.yAxis != null && series.yAxis!.isInversed
        ? points[0]
        : points[1];
    segmentBounds = Rect.fromLTRB(
        start.dx - hiloPadding, start.dy, end.dx + hiloPadding, end.dy);
  }

  if (segmentBounds.contains(position)) {
    return true;
  }

  return false;
}