BarTouchData constructor

BarTouchData({
  1. bool? enabled,
  2. BaseTouchCallback<BarTouchResponse>? touchCallback,
  3. MouseCursorResolver<BarTouchResponse>? mouseCursorResolver,
  4. Duration? longPressDuration,
  5. BarTouchTooltipData? touchTooltipData,
  6. EdgeInsets? touchExtraThreshold,
  7. bool? allowTouchBarBackDraw,
  8. bool? handleBuiltInTouches,
})

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 BarTouchResponse which contains information about the elements that has touched.

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

if handleBuiltInTouches is true, BarChart shows a tooltip popup on top of the bars if touch occurs (or you can show it manually using, BarChartGroupData.showingTooltipIndicators), You can customize this tooltip using touchTooltipData. If you need to have a distance threshold for handling touches, use touchExtraThreshold. If allowTouchBarBackDraw sets to true, touches will work on BarChartRodData.backDrawRodData too (by default it only works on the main rods).

Implementation

BarTouchData({
  bool? enabled,
  BaseTouchCallback<BarTouchResponse>? touchCallback,
  MouseCursorResolver<BarTouchResponse>? mouseCursorResolver,
  Duration? longPressDuration,
  BarTouchTooltipData? touchTooltipData,
  EdgeInsets? touchExtraThreshold,
  bool? allowTouchBarBackDraw,
  bool? handleBuiltInTouches,
})  : touchTooltipData = touchTooltipData ?? BarTouchTooltipData(),
      touchExtraThreshold = touchExtraThreshold ?? const EdgeInsets.all(4),
      allowTouchBarBackDraw = allowTouchBarBackDraw ?? false,
      handleBuiltInTouches = handleBuiltInTouches ?? true,
      super(
        enabled ?? true,
        touchCallback,
        mouseCursorResolver,
        longPressDuration,
      );