Closed zhalil closed 4 months ago
You can use decodeAvif to get an instance of a dart:ui Image
final bytes = await rootBundle.load('assets/test.avif');
final frames = await decodeAvif(bytes.buffer.asUint8List());
final avifImage = frames[0].image;
and draw it with drawImage in your custom painter.
import 'dart:ui' as ui;
class ImagePainter extends CustomPainter {
ui.Image? image;
ImagePainter(this.image);
@override
void paint(Canvas canvas, Size size) {
if (image != null) {
canvas.drawImage(image!, Offset.zero, Paint());
}
}
@override
bool shouldRepaint(ImagePainter oldDelegate) {
return oldDelegate.image != image;
}
}
CustomPaint(
painter: ImagePainter(avifImage),
),
Hello, is it possible to use avif in a custom paint widget somehow?