0

我正在使用 Rive 显示带有颤动的动画闪屏,但在最初的几秒钟内出现了这个错误(在加载文件时或在显示画板之前):

type 'Artboard' is not a subtype of type 'RuntimeArtboard' in type cast 
#0      Rive.createRenderObject (package:rive/src/rive.dart:42)
....

但实际上,如果我打开rive.dart:42我发现:

return RiveRenderObject(artboard as RuntimeArtboard)

如果我RuntimeArtboard开课,我发现:

class RuntimeArtboard extends Artboard

出现此错误后,文件正常加载,动画开始没有问题。

那么,为什么我会收到此错误?我应该忽略它还是有问题?

这是我的代码:

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rive/rive.dart';

class SplashScreen extends StatefulWidget {
  @override
  _SplashScreenState createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  Artboard artboard;
  RiveAnimationController controller;

  @override
  void initState() {
    super.initState();
    artboard = Artboard();
    rootBundle.load("assets/images/splash.riv").then((data) {
      final file = RiveFile.import(data);
      final artboard = file.mainArtboard;
      artboard.addController(controller = SimpleAnimation("splash"));
      setState(() => this.artboard = artboard);
    });
  }

  @override
  Widget build(BuildContext context) {
    return artboard != null
        ? Rive(
            artboard: artboard,
            fit: BoxFit.cover,
          )
        : SizedBox();
  }
}
4

0 回答 0