Lottie 资产加载在网络上但在我的移动设备上

问题描述

我正在将一些 lottie 动画加载到我的 Flutter 应用程序中,如下所示。当我在网络上预览它时,所有动画都加载良好,但是当我在真正的 android 设备上调试相同的代码I am getting unable to load asset:animations/track.json

这是我的代码

....
 child: SizedBox(
                  width: width * .8,height: height * .5,child: Lottie.asset(animation),//Where animation is for example = animations/track.json
                ),....

这是我的 pubspec.yaml

Flutter:
  uses-material-design: true
  assets:
    - assets/

这是我的动画目录

enter image description here

我该如何解决这个问题。我没时间解决这个问题了。

谢谢。

解决方法

您能否在 https://airbnb.io/lottie/#/supported-features 上检查您的彩票文件是否具有 Web 支持的功能,而不是 Android 支持的功能

此外,您可以尝试将其添加到 pubspec.yaml

的资产部分
- assets/animations/
- assets/fonts/
- assets/images/

不知道能不能用