Rive/Flutter - type 'Artboard' is not a subtype of type 'RuntimeArtboard' in type cast

652 Views Asked by At

I'm using Rive to display animated splash screen with flutter, but I got this error in the first few seconds (while loading the file or before displaying the artboard):

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

But actually, if I open rive.dart:42 I found:

return RiveRenderObject(artboard as RuntimeArtboard)

and if I open RuntimeArtboard class I found:

class RuntimeArtboard extends Artboard

After this error, the file loads normally and the animation starts without problems.

So, why I'm getting this error? should I ignore it or there is a problem with that?

This is my code:

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();
  }
}
0

There are 0 best solutions below