touchable icon indicating copy to clipboard operation
touchable copied to clipboard

Problems with Gesture Detector

Open meeximum opened this issue 3 years ago • 2 comments

Hi,

I'm using a GestureDetector around the CanvasTouchDetector, as I want to draw the shapes dynamically and the for example move the shapes per drag and drop!

When I use my coding

@override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      body: GestureDetector(
        behavior: HitTestBehavior.translucent,
        onPanUpdate: (details) {
          setState(() {
            RenderBox renderBox = context.findRenderObject() as RenderBox;
            points.add(DrawingPoints(
                points: renderBox.globalToLocal(details.globalPosition),
                paint: Paint()
                  ..strokeCap = strokeCap
                  ..isAntiAlias = true
                  ..color = selectedColor.withOpacity(opacity)
                  ..strokeWidth = strokeWidth));
          });
        },
        onPanStart: (details) {
          setState(() {
            RenderBox renderBox = context.findRenderObject() as RenderBox;
            points.add(DrawingPoints(
                points: renderBox.globalToLocal(details.globalPosition),
                paint: Paint()
                  ..strokeCap = strokeCap
                  ..isAntiAlias = true
                  ..color = selectedColor.withOpacity(opacity)
                  ..strokeWidth = strokeWidth));
          });
        },
        onPanEnd: (details) {
          setState(() {
            //points.add(null);
            print("Area: ${_calcualteArea()}");
          });
        },
        // child: CustomPaint(size: Size.infinite, painter: DrawingPainter(context, pointsList: points)),
        child: CanvasTouchDetector(
          builder: (context) => CustomPaint(size: Size.infinite, painter: DrawingPainter(context, pointsList: points)),
        ),
      ),
    );
  }

nothing happens no touch events where triggered :-/

meeximum avatar Dec 20 '21 19:12 meeximum

Hi, any luck in figuring this out? I have the same issue.

TheAfr0man avatar Mar 22 '22 05:03 TheAfr0man

Hi, any luck in figuring this out? I have the same issue.

I forked "touchable" and comment a few of events. Touchable preventing them to bubble up

oleksii-pimenov avatar Apr 12 '22 17:04 oleksii-pimenov