我按照使用 rive 影片工具在 Flutter 中添加啟影片面的教程進行操作,但啟影片面不會出現。
我關注的鏈接:- https://pub.dev/packages/rive_splash_screen
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 檔案中的代碼
uj5u.com熱心網友回復:
我已使用您的代碼和示例 rive 社區制作的影片來重現該問題。但我做不到,一切都按預期進行。所以請檢查以下步驟:
1-確保您的影片路徑正確添加到pubspec.yaml:
pubspec.yaml
flutter:
uses-material-design: true
assets:
- assets/
2-確保riv檔案的路徑在SplashScreen.navigate小部件中準確寫入。檢查提供的路徑中是否有一個uppercase。
home: SplashScreen.navigate(
name: 'assets/alarm.riv',
next: (_) => const MyHomePage(title: 'Demo App'),
until: () => Future.delayed(const Duration(seconds: 5)),
startAnimation: 'bell',
),
3- 最后,即使這不會導致此問題,請確保您提供正確的影片名稱。如果你不這樣做,影片會出現,但不會像預期的那樣影片。
檢查Github上的以下存盤庫。
如果您還有其他問題,請不要猶豫,在評論中寫下。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/486647.html
