Jewel Rana
Jewel Rana

Reputation: 2786

avif image format not supported in flutter

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)

Upvotes: 1

Views: 3232

Answers (3)

Greg Price
Greg Price

Reputation: 2989

That's right, AVIF is currently not supported by Flutter itself. There's an open issue for it here: https://github.com/flutter/flutter/issues/61229 . If AVIF support is important to you, then you can add a thumbs-up to the issue to help prioritize it.

As comments on that issue explain, Flutter uses the platform's decoder if one exists. So in particular for Android 12+, AVIF will work.

As another answer mentions (and is also in the issue thread), there is a third-party package that provides AVIF support for Flutter: https://pub.dev/packages/flutter_avif . So that's an option to consider if you need AVIF support.

Upvotes: 0

Fibert Loyee
Fibert Loyee

Reputation: 11

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

https://github.com/yekeskin/flutter_avif

Upvotes: 0

Md. Yeasin Sheikh
Md. Yeasin Sheikh

Reputation: 63549

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

Upvotes: 0

Related Questions