EP-u-NW / painter

A simple flutter widget to paint with your fingers
https://pub.dev/packages/painter
Other
137 stars 66 forks source link

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

Open NTJ3 opened 3 years ago

NTJ3 commented 3 years ago

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

CivelXu commented 3 years ago

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

kreativityapps commented 2 years ago

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!),
    ),
  ),