LineTouchData constructor

const LineTouchData({
  1. bool enabled = true,
  2. BaseTouchCallback<LineTouchResponse>? touchCallback,
  3. MouseCursorResolver<LineTouchResponse>? mouseCursorResolver,
  4. Duration? longPressDuration,
  5. LineTouchTooltipData touchTooltipData = const LineTouchTooltipData(),
  6. GetTouchedSpotIndicator getTouchedSpotIndicator = defaultTouchedIndicators,
  7. double touchSpotThreshold = 10,
  8. CalculateTouchDistance distanceCalculator = _xDistance,
  9. bool handleBuiltInTouches = true,
  10. GetTouchLineY getTouchLineStart = defaultGetTouchLineStart,
  11. GetTouchLineY getTouchLineEnd = defaultGetTouchLineEnd,
})

You can disable or enable the touch system using enabled flag,

touchCallback notifies you about the happened touch/pointer events. It gives you a FlTouchEvent which is the happened event such as FlPointerHoverEvent, FlTapUpEvent, ... It also gives you a LineTouchResponse which contains information about the elements that has touched.

Using mouseCursorResolver you can change the mouse cursor based on the provided FlTouchEvent and LineTouchResponse

if handleBuiltInTouches is true, LineChart shows a tooltip popup on top of the spots if touch occurs (or you can show it manually using, LineChartData.showingTooltipIndicators) and also it shows an indicator (contains a thicker line and larger dot on the targeted spot), You can define how this indicator looks like through getTouchedSpotIndicator callback, You can customize this tooltip using touchTooltipData, indicator lines starts from position controlled by getTouchLineStart and ends at position controlled by getTouchLineEnd. If you need to have a distance threshold for handling touches, use touchSpotThreshold.

Implementation

const LineTouchData({
  bool enabled = true,
  BaseTouchCallback<LineTouchResponse>? touchCallback,
  MouseCursorResolver<LineTouchResponse>? mouseCursorResolver,
  Duration? longPressDuration,
  this.touchTooltipData = const LineTouchTooltipData(),
  this.getTouchedSpotIndicator = defaultTouchedIndicators,
  this.touchSpotThreshold = 10,
  this.distanceCalculator = _xDistance,
  this.handleBuiltInTouches = true,
  this.getTouchLineStart = defaultGetTouchLineStart,
  this.getTouchLineEnd = defaultGetTouchLineEnd,
}) : super(
        enabled,
        touchCallback,
        mouseCursorResolver,
        longPressDuration,
      );