创建了一个应用程序,以学习在Flutter应用程序项目中添加Rive Splash屏幕动画
我遵循了使用Rive Animation Tool在flutter中在应用程序中添加飞溅屏幕的教程,但是溅起屏幕不会显示。
我遵循的链接: -
import 'package:flutter/material.dart';
import 'package:rive_splash_screen/rive_splash_screen.dart';
import 'package:rive/rive.dart';
import 'dart:ui';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: SplashScreen.navigate(
name: 'assets/doublersplashscreen.riv',
next: (_) => const MyHomePage(),
until: () => Future.delayed(const Duration(seconds: 5)),
startAnimation: 'Splash',
),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
color: Colors.red,
height: 400,
width: 300,
);
}
}
pubspec.yaml文件中的代码
I followed the tutorial of adding a splash screen in an app in flutter using rive animation tool, but the splash screen won't show up.
Link which i followed:- https://pub.dev/packages/rive_splash_screen
Code in main.dart file
import 'package:flutter/material.dart';
import 'package:rive_splash_screen/rive_splash_screen.dart';
import 'package:rive/rive.dart';
import 'dart:ui';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: SplashScreen.navigate(
name: 'assets/doublersplashscreen.riv',
next: (_) => const MyHomePage(),
until: () => Future.delayed(const Duration(seconds: 5)),
startAnimation: 'Splash',
),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
color: Colors.red,
height: 400,
width: 300,
);
}
}
Code in pubspec.yaml file
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经使用了您的代码和Rive的社区制作动画来复制该问题。但是我不能,一切都按预期工作。因此,请检查以下步骤:
1-确保您的动画路径正确添加到
pubspec.yaml
:pubspec.yaml
2-确保
riv
文件的路径精确地写在splashscreen.navigate
widget中。检查提供的路径中是否有大写
。3-最后,即使无法引起此问题,也要确保您提供正确的动画名称。如果不这样做,动画将出现,但不会像预期的那样动画。
在
如果您有其他问题,请随时写在评论中。
I have used your code and a sample rive's community-made animation to reproduce the issue. But I could not, and everything worked as expected. So please check the following steps:
1- Be sure that your animation path is added correctly to
pubspec.yaml
:pubspec.yaml
2- Be sure that the
riv
file's path is written accurately in theSplashScreen.navigate
widget. Check if there is anuppercase
in the provided path.3- Lastly, even if this can not be causing this problem, be sure that you are providing the correct animation name. If you don't, animation will show up but won't animate as expected.
Check the following repository on Github.
If you have further problems, please don't hesitate to write in the comments.