TouchyCanvas constructor

TouchyCanvas(
  1. BuildContext context,
  2. Canvas _canvas, {
  3. ScrollController? scrollController,
  4. AxisDirection scrollDirection = AxisDirection.down,
})

TouchyCanvas helps you add gesture callbacks to the shapes you draw.

context is the BuildContext that is obtained from the CanvasTouchDetector widget's builder function. The parameter canvas is the Canvas object that you get in your paint method inside CustomPainter

Implementation

TouchyCanvas(
  BuildContext context,
  this._canvas, {
  ScrollController? scrollController,
  AxisDirection scrollDirection = AxisDirection.down,
}) {
  var touchController = TouchDetectionController.of(context);
  touchController?.addListener((event) {
    _shapeHandler.handleGestureEvent(
      event,
      scrollController: scrollController,
      direction: scrollDirection,
    );
  });
}