Incorrect Gesture Arguments
Error : "The following assertion was thrown building CanvasTouchDetector(dirty, state: _CanvasTouchDetectorState#56194): Incorrect GestureDetector arguments.
Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan.
Just use the scale gesture recognizer."
I wanted to use only tap so deleting other gesture detectors solved the problem for me
I started getting same error once I upgraded Flutter to 3.0.5
Fixed by specifying used gestures: gesturesToOverride: [GestureType.onTapDown]
That's it! Thank your so much, @srdjan86 !
Even I was facing the same issue so I implemented what others have suggested, after implementing it I'm able to see the drawing but not able to trigger the events. Below given is m code snippet please help me out with this
import 'package:flutter/material.dart'; import 'package:touchable/touchable.dart';
class Bevel extends StatelessWidget { @override Widget build(BuildContext context) { return Container( color: Colors.white, child: CanvasTouchDetector( gesturesToOverride: const [GestureType.onTapDown], builder: (context) => CustomPaint( painter: MyPainter(context), ), ), ); } }
class MyPainter extends CustomPainter { final BuildContext context; MyPainter(this.context);
@ override void paint(Canvas canvas, Size size) { TouchyCanvas touchyCanvas = TouchyCanvas(context, canvas);
var blueCircle = Offset(size.width / 2, size.height / 2 - 100);
var greenCircle = Offset(size.width / 2, size.height / 2 + 100);
touchyCanvas.drawCircle(blueCircle, 60, Paint()..color = Colors.blue,
onTapDown: (_) {
print('You clicked BLUE circle');
});
touchyCanvas.drawCircle(greenCircle, 30, Paint()..color = Colors.green,
onLongPressStart: (_) {
print('long pressed on GREEN circle');
});
}
@ override bool shouldRepaint(MyPainter oldDelegate) { return false; } }