How to set the opacity of an image drawn to a canvas with drawImageRect? How to set the opacity of an image drawn to a canvas with drawImageRect? dart dart

How to set the opacity of an image drawn to a canvas with drawImageRect?


Just set the color opacity

final _paint = Paint();final opacity = 0.5;_paint.color = Color.fromRGBO(0, 0, 0, opacity);canvas.drawImageRect(image, sourceRect, destRect, _paint);


You can process the image before rendering using this library. Also I would suggest you to do all operations of this library using the isolates, using the compute() function of flutter would be easy as it blocks the whole UI.