yellowQ-software / yellowQ-Flutter-Image-Painter

Flutter package for painting on images
MIT License
106 stars 117 forks source link

Scaling mode is not preventing draw mode #7

Closed ynnob closed 3 years ago

ynnob commented 3 years ago

Problem

If the mode scalable is set to true the ImagePainter does not prevent painting while scaling. Also this mode should be called zoom instead of scaling because the scaling of the image is not saved.

Solution

Implement a Listener wrapped around the canvas that handles the current FingerCount:

[...] Listener(
      onPointerDown: (_) => increaseFingerCount(),
      onPointerUp: (_) => decreaseFingerCount(),
      child: [...]

Then cancel painting when the fingerCount is == 2

if (_fingerCount == 2) {
   return;
}
lively-bigyan commented 3 years ago

Thank you for opening up the issue. The implementation was done on the previous versions of app but It felt kind of redundant to do this because painting begins when user starts touching. Although it did prevent further painting while zooming, it didn't do much for the initially painted ones so it was removed for latest versions during refactors. It will be included in future versions of the package. For the mode, I think your suggestion makes sense. I'll make sure to include that in upcoming versions.