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

NoSuchMethodError: The method '[]' was called on null. #19

Open blazvantur opened 5 years ago

blazvantur commented 5 years ago

Hey.

I'm having trouble parsing my Flare file in the flutter: I get a weird error The method '[]' was called on null.

Flutter code:

child: FlareActor(
                    "resources/animations/animated_house.flr",
                    animation: "Enter transition",
                  ),

Stacktrace:

[ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
    NoSuchMethodError: The method '[]' was called on null.
    Receiver: null
    Tried calling: [](0)
    #0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
    #1      JSONReader._readArrayOffset (package:flarecode/flare/json_reader.dart:59:22)
    #2      JSONReader.readFloat32ArrayOffset (package:flarecode/flare/json_reader.dart:45:10)
    #3      KeyFramePathVertices.read (package:flarecode/flare/animation/keyframe.dart:699:14)
    #4      PropertyAnimation.read (package:flarecode/flare/animation/actor_animation.dart:148:38)
    #5      ComponentAnimation.read (package:flarecode/flare/animation/actor_animation.dart:230:61)
    #6      ActorAnimation.read (package:flarecode/flare/animation/actor_animation.dart:422:30)
    #7      ActorArtboard.readAnimationsBlock (package:flarecode/flare/actor_artboard.dart:561:30)
    #8      ActorArtboard.read (package:flarecode/flare/actor_artboard.dart:310:11)
    #9      Actor.readArtboardsBlock (package:flarecode/flare/actor.dart:160:22)
    #10     Actor.load (package:flarecode/flare/actor.dart:139:11)
    #11     FlutterActor.loadFromBundle.<anonymous closure> (package:flarecode/flare.dart:507:13)
    #12     _RootZone.runUnary (dart:async/zone.dart:1379:54)
    #13     _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
    #14     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
    #15     Future._propagateToListeners (dart:async/future_impl.dart:671:32)
    #16     Future._complete (dart:async/future_impl.dart:476:7)
    #17     _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
    #18     _AsyncAwaitCompleter.complete (dart:async/runtime/libasync_patch.dart:28:18)
    #19     _completeOnAsyncReturn (dart:async/runtime/libasync_patch.dart:295:13)
    #20     PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart)
    <asynchronous suspension>
    #21     FlutterActor.loadFromBundle (package:flarecode/flare.dart:506:16)
    <asynchronous suspension>
    #22     FlareActorRenderObject.filename= (package:flarecode/flare_actor.dart:208:13)
    #23     FlareActor.createRenderObject (package:flarecode/flare_actor.dart:44:9)
    #24     RenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4482:28)
    #25     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
    #26     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
    #27     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
    #28     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
    #29     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
    #30     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
    #31     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
    #32     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
    #33     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
    #34     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
    #35     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
    #36     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
    #37     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
    #38     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
    #39     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
    #40     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
    #41     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
    #42     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
    #43     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
    #44     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
    #45     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)

Flutter file: https://www.2dimensions.com/a/bvantur/files/flare/animated-house-2/preview

Also, I have noticed that in preview door doesn't get opened as they get opened inside of a Flare editor. I have tried exporting .flr file as Binary and JSON format.

luigi-rosso commented 5 years ago

Thanks for reporting. I think this was due to an out of sync package on pub. We just published an update.

Make sure you're using the latest flare_flutter (^1.0.3) in your pubspec. You could also pub upgrade flare_flutter.

Let me know if that helps.

blazvantur commented 5 years ago

Thanks for the quick reply. I have tried your suggestion but with no luck. I'm now using ^1.0.3 version and I've also tried to update with pub upgrade but I'm stuck with the same error as before.

You can check the content of animated_house.flr file here: https://jsoneditoronline.org/?id=a3ec501c58264ad1b0149aa6444df17b Is there maybe some operation that is not supported by flare_flutter package?

luigi-rosso commented 5 years ago

I see it works with the binary version now, it just looks like the json format is broken with the latest build. Please use that while we investigate this further!

screen shot 2018-12-15 at 4 37 07 pm