How to solve format exception with flare?

Viewed 3203

I'm using flare but I get this error, error goes away when I use CircularProgressIndicator().

[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FormatException: Unexpected character (at character 1)
E/flutter ( 7668): PK

Here's the code:

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

class LoadingIndicator extends StatelessWidget {
  Widget build(BuildContext context) {
    return Center(
      // child: CircularProgressIndicator(),
      child: FlareActor(
        "assets/loading_1.flr2d",
        alignment: Alignment.center,
        fit: BoxFit.contain,
        animation: "loading",
      ),
    );
  }
}

SOLUTION

When I've downloaded Flare graphics from Explore page of 2Dimensions, I was downloading .flr2d files. Which was I guess a project fiel. In flare, you have to export rather than download. I've exported as binary and the output file has .flr extension. Thanks @Noob for helping me to find the answer.

2 Answers

As Noob mentioned your file needs to be a .flr

If you are downloading from 2 dimension's page then you need to go to Export at top right from Flare editor. Then select file format as JSON not binary. You should be then downloading the asset as a .flr file.

Flutter only supports .flr and not .flr2d

I know this because I was running into the same issue.

The animation needs to be created into an flr file otherwise you will always run into this error.

Related