How to fill an image on flutter canvas?

216 Views Asked by At

I have a class that extends CustomPainter, which helps me to draw an image on the canvas (with canvas.drawImage) and plot some points (with canvas.drawLine and canvas.drawPath) on top of the image. However, I have trouble figuring out how to scale or translate the image so that it fills / covers the canvas (about 60% of the image from the center should be displayed within the screen size of the device). The image can be bigger or smaller than the device's screen size, but they all have a fixed aspect ratio (4:3). I would like to fill the image on the canvas (following the 60% rule above) and scaling them according to their original aspect ratio.

A pseudocode or a general idea on how to do this would be appreciated.

0

There are 0 best solutions below