lottie-flutter icon indicating copy to clipboard operation
lottie-flutter copied to clipboard

Referencing svgs from lottie animation

Open appycamper opened this issue 5 years ago • 2 comments

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?

appycamper avatar May 21 '20 13:05 appycamper

It's not supported right now. But it's a good feature request.

There is several possibilities:

  • Convert the svg to a ui.Image at load time and reference the ui.Image from the composition. This probably could be done right now with the imageProviderFactory that returns a MemoryImage. 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_svg directly 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.

xvrh avatar May 22 '20 12:05 xvrh

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.

appycamper avatar May 22 '20 13:05 appycamper