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

Unable to load asset from Lottie.asset().

Open Solider1337 opened this issue 1 year ago • 4 comments

Loading an asset from a file does not work. I tried with .zip and .json. There are no errors other than that in the application screen. Everything works fine with Lottie.network, but I need to load the animations from a file. I searched the internet for a long time but found no solution. I tried the old lottie versions but it didn't fix the problem.

image image image

Lottie version: lottie: ^1.4.2

Flutter doctor: image

Run: image

Solider1337 avatar Sep 11 '22 00:09 Solider1337

I think you either have to declare your assets without the "packages" path:

  assets:
    - assets/images/118839-sleeping-piggy.zip

or use the package parameter in the Lottie.asset constructor:

Lottie.asset('assets/images/118839-sleeping-piggy.zip', package: 'pizzaparty')

xvrh avatar Sep 11 '22 14:09 xvrh

It did not help. image image

If I use Lottie.asset('assets/images/118839-sleeping-piggy.zip', package: 'pizzaparty') error changes to Bad state: No element

Solider1337 avatar Sep 11 '22 21:09 Solider1337

I checked your solution again, but on .json it works! image

Lottie.asset('assets/images/75816-delivering-pizzas.json', package: 'pizzaparty')

assets: - packages/pizzaparty/assets/images/75816-delivering-pizzas.json

The .zip still doesn't work, but that is a minor problem. Thanks!!

Solider1337 avatar Sep 11 '22 21:09 Solider1337

Can you send the .zip file to check why it doesn't load?

xvrh avatar Sep 12 '22 06:09 xvrh