xvrh / lottie-flutter

Render After Effects animations natively on Flutter. This package is a pure Dart implementation of a Lottie player.
https://pub.dev/packages/lottie
MIT License
1.16k stars 196 forks source link

perf: makes static compositions not animate by default #265

Closed Ascenio closed 1 year ago

Ascenio commented 1 year ago

Hello folks.

At the company I work for we use lottie files for everything, animations, icons and static "images". We noticed for the case when the lottie is static there is still an animation running, which hurts performance overtime if we consider an app with lots of these. Also, it makes tests harder as there will be always frames to be pumped.

The solution is simple. All you need is to pass animate: false to every static asset. However, we believe that this is a sensible default and lots of projects could benefit from it. All it takes is to verify if there is only one frame to be shown, and if that's the case we assume animate: false.

Before

https://user-images.githubusercontent.com/7662016/218285152-31384d2e-31d7-44c9-b248-33b839c811a1.mov

After

https://user-images.githubusercontent.com/7662016/218285155-2b31122a-fe9f-43c5-9586-329be99e8393.mov

Ascenio commented 1 year ago

@xvrh could you take a look? ;)

xvrh commented 1 year ago

Thanks for the contribution!