painter icon indicating copy to clipboard operation
painter copied to clipboard

Disable Multi-Touch | While moving two fingers on canvas painting gets destroyed.

Open NTJ3 opened this issue 3 years ago • 2 comments

I'm facing the issue while accidentally second finger touch the canvas then drawing gets distracted.

@EPNW It's recommended feature to add supports of Disable Multi-Touch while drawing.

Can anyone have an idea about it?

Thanks in advance :)

@fluttercommunity

NTJ3 avatar Jun 15 '21 14:06 NTJ3

I have the same problem, is there a good solution?

CivelXu avatar Jun 24 '21 03:06 CivelXu

One way to do it is to wrap Painter in a Listener widget.

int _pointers = 0; // will detect the number of fingers touching the widget

Listener(
    onPointerDown: (event) {
      if (!mounted) return;
      setState(() {
        _pointers++;
      });
    },
    onPointerUp: (event) {
      if (!mounted) return;
      setState(() {
        _pointers--;
      });
    },
    child: IgnorePointer(
      ignoring: _pointers > 1,
      child: _pointers > 1 ? null : Painter(_paintController!),
    ),
  ),

kreativityapps avatar Oct 12 '21 21:10 kreativityapps