avif image format not supported in flutter

2.3k Views Asked by At

I got avif image from server but image not showing.

I have tried Image.network() and CachedNetworkImage to show avif image .

Exception: Invalid image data

When the exception was thrown, this was the stack: 
#0      _futurize (dart:ui/painting.dart:5326:5)
#1      ImageDescriptor.encoded (dart:ui/painting.dart:5194:12)
#2      instantiateImageCodec (dart:ui/painting.dart:2048:60)
<asynchronous suspension>
Image provider: NetworkImage("https://www.soppiya.com/media/images/610fc7bb172b28ecf8655216/item/6122493b75ca8186640a03ae/image1.avif?x=62433", scale: 1.0)
Image key: NetworkImage("https://www.soppiya.com/media/images/610fc7bb172b28ecf8655216/item/6122493b75ca8186640a03ae/image1.avif?x=62433", scale: 1.0)
2

There are 2 best solutions below

0
Md. Yeasin Sheikh On

You can convert the image, while this is format is not supported.

The following image formats are supported: JPEG, PNG, GIF, Animated GIF, WebP, Animated WebP, BMP, and WBMP.

For more, read Image-class

1
Fibert Loyee On

Here is a Flutter library that is capable of decoding and encoding AVIF photos.

https://github.com/yekeskin/flutter_avif