【问题标题】:Unable to load animation.json file to my flutter project无法将 animation.json 文件加载到我的颤振项目中
【发布时间】:2020-12-14 18:17:21
【问题描述】:

我使用 bodymovin 从 Aftereffect 导出了 animation.json 文件,但无法将其加载到我的颤振项目中。

我关注了这个媒体article,但在将文件路径放在 pubspec.yaml 文件的资产中之后,我也无法渲染动画。

我试图将我的代码简化为:

import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: ListView(
          children: [
            // Load a Lottie file from your assets
            Lottie.asset('assets/optimal.json'),

            // Load a Lottie file from a remote url
            Lottie.network(
                'https://raw.githubusercontent.com/xvrh/lottie-flutter/master/example/assets/Mobilo/A.json'),

            // Load an animation and its images from a zip file
            // Lottie.asset('assets/lottiefiles/angel.zip'),
          ],
        ),
      ),
    );
  }
}

这是错误信息:


> FAILURE: Build failed with an exception.
> 
> * Where: Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line:
> 904
> 
> * What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
> > Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
> 
> * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
> 
> * Get more help at https://help.gradle.org
> 
> BUILD FAILED in 44s Exception: Gradle task assembleDebug failed with
> exit code 1

【问题讨论】:

    标签: json flutter android-animation lottie bodymovin


    【解决方案1】:

    您可以尝试删除pubspec.lock 并使用flutter pub get 安装软件包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-09
      • 2020-04-26
      • 2021-07-30
      • 2020-01-16
      • 1970-01-01
      • 2019-08-19
      • 2020-02-06
      • 2020-03-12
      相关资源
      最近更新 更多