我使用 bodymovin 从 Aftereffect 导出了 animation.json 文件,但无法将其加载到我的颤振项目中。
我关注了这篇中篇文章,但在将文件路径放入 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