Skip to content

Problems with Gesture Detector #41

@meeximum

Description

@meeximum

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 :-/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions