Referencing svgs from lottie animation
example.zip Hi,
I've attached an example of an animation that references an svg but unfortunately the svg image does not show up.
I've tried using something like flutter_svg but this doesn't have an imageprovider that is compatible with lottie.
are svgs currently supported?
It's not supported right now. But it's a good feature request.
There is several possibilities:
- Convert the svg to a
ui.Imageat load time and reference theui.Imagefrom the composition. This probably could be done right now with theimageProviderFactorythat returns aMemoryImage. The disadvantage of this technique is that you have to rasterize the image at a specific size ahead of time and you won't have the perfect pixel density. - Integrate the support for
flutter_svgdirectly in this library. We will have a new dependency and every one will pay the cost in term of code size. - Add a customisable callback to paint the images. Anyone from outside of this library can link the image drawing code to any third party library.
Thanks, I'll try out your first suggestion. It'd be great if the library supported svg out of the box but I'm not sure how niche this use case is. In case it isn't a popular use case I'd suggest adding a customisable callback so I can use a third party library like flutter_svg.