7

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.

mirkancal
  • 4,762
  • 7
  • 37
  • 75
  • Check your path, if your path is not the issue then check how you had exported your Flare file, 2Dimensions have support over several channels. – Mariano Zorrilla Jun 27 '19 at 16:01
  • You are welcome @mirkancal. can you please mark my answer as correct, that would be great :) – Noob Feb 10 '22 at 03:18

2 Answers2

11

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.

Shababb Karim
  • 3,614
  • 1
  • 22
  • 35
  • Thanks but I've already added the solution on the original post. Exporting binary works too by the way. – mirkancal Jul 10 '19 at 08:44
  • Ow alright. I was looking at this comment https://stackoverflow.com/questions/56794046/how-to-solve-format-exception-with-flare/56966767?noredirect=1#comment100278015_56845932 but thought I should add something extra for others to find easily – Shababb Karim Jul 10 '19 at 10:16
9

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.

Noob
  • 319
  • 1
  • 3
  • 16
  • That's useful. Let me try it. – mirkancal Jul 02 '19 at 07:24
  • looks like all the downloaded files now have .flr2d file extension. How can I download .flr or convert them? – mirkancal Jul 02 '19 at 14:42
  • @mirkancal I am not too sure on where you are getting your flare files, but if you are creating them, you need to export the flare file into .flr but if you are already using someone elses built flare file then I am not sure you can change a flare file already created. you need to go to the source – Noob Jul 03 '19 at 01:05
  • I'm downloading them from explore page of 2dimensions. https://www.2dimensions.com/explore/popular/trending/all – mirkancal Jul 03 '19 at 06:58
  • any idea how to open these files in photoshop so that I can save them as png? – Pushan Gupta Jul 09 '19 at 06:11