Flutter Touchable CanvasTouchDetector tap events not firing

Viewed 102

I am trying to add input to my canvas and have found the touchable library (found here: https://github.com/nateshmbhat/touchable) which is exactly what I am looking for, however the events do not seem to be getting fired in my code. I have set up my CanvasTouchDetector like so:

return Scaffold(
        appBar: AppBar(title: Text('Lights'), centerTitle: true),
        body: CanvasTouchDetector(
            builder: (context) => CustomPaint(
                painter: LevelPainter(
                    switches: this._switches,
                    connections: this._connections,
                    context: context),
                child: Center(child: Container()))));

This uses my own custom painter class called LevelPainter, which has the function:

void _drawSwitch(TouchyCanvas canvas, Paint paint, Switchable switchable) {
    paint.style = PaintingStyle.fill;
    paint.color = Colors.grey;
    canvas.drawRRect(this._getRectForSwitchable(switchable), paint,
        onTapDown: (tapDetail) {
      print('SWITCH PRESSED');
    });
  }

This method gets called for all the switches which I am rendering on my canvas, however this print statement never seem to get output.

0 Answers
Related