1

I am trying to make something like a magnifying glass on a Custom Painter. So far I am able to use Backdropfilter with imagefilter matrix scaling like below:

BackdropFilter(
  filter: ImageFilter.matrix(matrix),
  child : CustomFocusCircle()
),

While it works with Stack and Positioned, I wonder if it is possible to create it on canvas. I tried something like this and it kind of worked.

canvas.drawAtlas(
              sourceImage,
              [
                /* Identity transform */
                RSTransform.fromComponents(
                  rotation: 0.0,
                  scale: 1,
                  anchorX: 0,
                  anchorY: 0,
                  translateX: 0,
                  translateY: 0,
                )
              ],
              [ 
                Rect.fromCircle(
                    center: Offset(size.width / 2, size.height / 2),
                    radius: 200),
                
              ],
              [],
              null,
              null,
              Paint());

But I am still not able to figure out how to make it a circular cutout instead of a rectangular one.

Zero Live
  • 1,653
  • 5
  • 22
  • 44

1 Answers1

0

Have you try this package https://pub.dev/packages/magnifying_glass ? you can try this package I hope this may help you.

  • Thank you for the response. But I am specifically looking to utilize `CustomPainter` canvas rather than a `Stack` widget like I mentioned in the question. The above package seems to use similar effect like my first solution on question but I am looking for second solution. – Zero Live Apr 28 '22 at 17:55