Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touch event fire multi times unexpected #54

Open
taosimple opened this issue Jan 12, 2023 · 1 comment
Open

Touch event fire multi times unexpected #54

taosimple opened this issue Jan 12, 2023 · 1 comment

Comments

@taosimple
Copy link

taosimple commented Jan 12, 2023

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: [
        Expanded(
          child: CustomPaint(
            foregroundPainter: SelectionPainter(notifier: notifierForeground),
            child: RepaintBoundary(
              child: CanvasTouchDetector(
                //key: UniqueKey(),
                gesturesToOverride: const [
                  GestureType.onTapDown,
                ],
                builder: (BuildContext context) {
                  return CustomPaint(
                    isComplex: true,
                    willChange: false,
                    painter: ChartPainter<D, Rx, Ry>(
                      onItemSelected: (List<Rect> selectionRects, item, index, xAxisIndex, layer, tapEvent) {
                        notifierForeground.value = selectionRects;
                        _showTooltip(selectionRects);
                      },
                    ),
                  );
                },
              ),
            ),
          ),
        ),
      ],
    );
  }

After state.build called multi times, onTapDown event will also fire multi times with one click. It seems pre touch rects not cleared ?

Workaround: add UniqueKey to CanvasTouchDetector

@Sri-Kumaran-DR
Copy link

Sri-Kumaran-DR commented Mar 6, 2024

@taosimple workaround didn't help in my case. I have it wrapped in an InteractiveViewer. It still fires it multiple times

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants