Android 上的 Flutter Lottie 动画启动画面
我想在 Flutter Android 应用程序中添加 Lottie 动画作为启动屏幕。我希望它在 Flutter 绘制第一帧之前启动,所以我正在考虑在本地执行此操作。
我在网上找到了两个例子,但它们都使用了 Flutter 已弃用的 SplashScreen
:
我在构建过程中收到以下警告消息:
W/FlutterActivityAndFragmentDelegate(23263): A splash screen was
provided to Flutter, but this is deprecated. See
flutter.dev/go/android-splash-migration for migration steps.
有没有办法制作像这个视频这样的启动动画:
- 接受 Lottie 格式
- 在 Flutter 绘制第一个之前的冷启动期间可见框架
- 不使用已弃用的 Flutter SplashScreen
尝试过的方法不起作用:
- Android 12 SplashScreen 似乎仅适用于动画矢量可绘制 (AVD) 格式的动画。
- flutter_native_splash 包尚不支持 Lottie 动画格式,尽管文档指出他们会接受 PR添加支持。

视频由 flutter_animated_splash_screen 提供。
I want to add a Lottie animation as a splash screen in a Flutter Android app. I would like it to start before Flutter draws its first frame, so I'm thinking about doing it natively.
I found two examples online but they both use Flutter's deprecated SplashScreen
:
I get the following warning message during build:
W/FlutterActivityAndFragmentDelegate(23263): A splash screen was
provided to Flutter, but this is deprecated. See
flutter.dev/go/android-splash-migration for migration steps.
Is there any way to do a splash animation like this video that:
- Accepts Lottie format
- Visible during a cold start before Flutter draws its first frame
- Doesn't use the deprecated Flutter SplashScreen
Things tried that didn't work:
- The documentation for Android 12 SplashScreen only seems to works for Animated Vector Drawable (AVD) format animations.
- The flutter_native_splash package doesn't support the Lottie animation format yet, though the documentation states that they would accept a PR adding support.
Video courtesy of flutter_animated_splash_screen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用包 lottie
创建一个有状态的启动屏幕:
现在将其用作:
现在在
initState 中
,您可以调用一个函数,该函数可以根据用户的状态或您的用例导航到主/登录屏幕。例如:
在
initState
中调用gotoaPage()
Use the package lottie
Create a stateful Splash Screen:
Now use it as :
Now in the
initState
, you can call a function which can navigate to the home/login screen depending on the status of the user or whatever your use-case is.For eg:
Call
gotoaPage()
in theinitState