2d-inc/Flare-Flutter

RangeError on app relaunch

kasyrm opened this issue · 0 comments

We are using Flare to display different animations based of api response. Thanks for the library!
We've noticed that sometimes after relaunching the app it gives us this error:

════════ Exception caught by widgets library ═══════════════════════════════════
The following RangeError was thrown building Container-[<'animation'>](constraints: BoxConstraints(w=40.0, h=40.0)):
RangeError (index): Invalid value: Not in range 0..4, inclusive: 5

User-created ancestor of the error-causing widget was
    Row 
lib/…/rows/feed_item.dart:46
When the exception was thrown, this was the stack
#0      List.[]  (dart:core-patch/array.dart:13:52)
#1      ComponentAnimation.apply 
package:flare_dart/animation/actor_animation.dart:242
#2      ActorAnimation.apply 
package:flare_dart/animation/actor_animation.dart:396
#3      FlareActorRenderObject.advance 
package:flare_flutter/flare_actor.dart:357
#4      FlareActorRenderObject._instanceArtboard 
package:flare_flutter/flare_actor.dart:291
...

Code:

@override
  Widget build(BuildContext context) {
    return StreamBuilder<Weather>(
        stream: _weatherBloc.stream,
        builder: (context, snapshot) {
          if (snapshot.hasData) {
            final animationName = snapshot.data.getAnimationName();
            return Column(
              children: <Widget>[
                Container(
                    padding: EdgeInsets.symmetric(horizontal: 14),
                    child: Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: <Widget>[
                          Container(
                            height: 40,
                            width: 40,
                            key: Key(AppKeys.animation),
                            child: FlareActor(
                              "assets/animation.flr",
                              alignment: Alignment.center,
                              fit: BoxFit.contain,
                              artboard: animationName,
                              animation: animationName,
                            ),
                          ),
                          Text("${snapshot.data.temp.round()}°",
                              key: Key(AppKeys.text),
                              style: AppTextStyles.style)
                        ])),
                Image.asset(
                  "assets/myImage.jpg",
                ),
              ],
            );
         } else {
            return Container(height: 7);
          }
        });
  }

It never happens on clean install. Do you have some suggestion why this might happen?