创建了一个应用程序,以学习在Flutter应用程序项目中添加Rive Splash屏幕动画

发布于 2025-02-04 11:35:37 字数 1546 浏览 3 评论 0原文

我遵循了使用Rive Animation Tool在flutter中在应用程序中添加飞溅屏幕的教程,但是溅起屏幕不会显示。

我遵循的链接: -

main.dart文件

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文件中的代码

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

Code in pubspec.yaml file

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凌乱心跳 2025-02-11 11:35:37

我已经使用了您的代码和Rive的社区制作动画来复制该问题。但是我不能,一切都按预期工作。因此,请检查以下步骤:

1-确保您的动画路径正确添加到pubspec.yaml

pubspec.yaml

flutter:

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

2-确保riv文件的路径精确地写在splashscreen.navigate widget中。检查提供的路径中是否有大写

home: SplashScreen.navigate(
  name: 'assets/alarm.riv',
  next: (_) => const MyHomePage(title: 'Demo App'),
  until: () => Future.delayed(const Duration(seconds: 5)),
  startAnimation: 'bell',
),

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

flutter:

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

2- Be sure that the riv file's path is written accurately in the SplashScreen.navigate widget. Check if there is an uppercase in the provided path.

home: SplashScreen.navigate(
  name: 'assets/alarm.riv',
  next: (_) => const MyHomePage(title: 'Demo App'),
  until: () => Future.delayed(const Duration(seconds: 5)),
  startAnimation: 'bell',
),

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文