Converts HEIC into PNG/JPEG/GIF using heic2any.
Useful in case your users are uploading HEIC images to your Flutter web app that need to be displayed correctly, as HEIC is not supported by most browsers.
Web only
- Please download a copy of
heic2any.min.js
on alexcorvi.github.io/heic2any - Save it in your Flutter project's
web
folder, next toindex.html
- Link the script in your
index.html
, like so:<script src="heic2any.min.js" type="application/javascript"></script>
- Add a new script tag to your
index.html
, with the following content:<script> function executeHeic2any(blob, multiple, toType, quality, gifInterval) { return heic2any({ blob, multiple: multiple, toType: toType, quality: quality, gifInterval: gifInterval }); } </script>
import "package:heckofaheic/heckofaheic.dart";
Future<void> myFunction() async {
Uint8List imageBytes = await getYourImageBytesSomehow();
if (HeckOfAHeic.isHEIC(imageBytes)) {
imageBytes = await HeckOfAHeic.convert(imageBytes);
}
}
For the full API documentation, please refer to the API reference.
have fun.