2d-inc / Flare-Flutter

Load and get full control of your Rive files in a Flutter project using this library.
https://rive.app/
MIT License
2.55k stars 469 forks source link

FlareActor not displaying in { environment: sdk: ">=2.1.0 <3.0.0" } #241

Open uxrefiner opened 4 years ago

uxrefiner commented 4 years ago

I created a simple animation with Rive of a red square moving across the screen to test out importing it into a Flutter app. I used "flutter create" in the terminal to create a fresh flutter project to test this out, and I was unable to get the Rive animation to display using FlareActor until I changed the sdk version in the pubspec.yaml file.

Tested on:

Flutter pubspec.yaml:

environment: sdk: ">=2.1.0 <3.0.0" //FlareActor not displaying

environment: sdk: ">=2.0.0-dev.68.0 <3.0.0" //FlareActor displaying

I made sure to keep the code as simple as possible to eliminate any potential errors. Here is my main.dart file:

import 'package:flare_flutter/flare_actor.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return new FlareActor("assets/red_square.flr",
        alignment: Alignment.center,
        fit: BoxFit.contain,
        animation: "red_square");
  }
}

Here is the full yaml file of the project with FlareActor not displaying:

name: flare_actor_broken
description: A new Flutter project.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flare_flutter: 2.0.1

  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:

  uses-material-design: true

  assets:
  - assets/

Here is the full .yaml of the project with the FlareActor displaying:

name: flare_actor_working
description: A new Flutter application.

version: 1.0.0+1

environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flare_flutter: 2.0.1

  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:

  uses-material-design: true

  assets:
  - assets/
justkawal commented 4 years ago

Same Issue happening here