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 470 forks source link

cachedActor example is no longer working #224

Closed tsinis closed 4 years ago

tsinis commented 4 years ago

Hello!

Dear Rive Team, first and foremost, thank you very much for this amazing tool, it is unprecedented. There is an issue with cachedActor function, it's not working anymore in flare_flutter 2.0.1, like in your example code: https://github.com/2d-inc/developer_quest/blob/8a7ef09687309c4f48ef040c091fbb44e7b1b909/lib/src/widgets/flare/warmup_flare.dart#L30

Could you please provide updated example of animation caching? Thank you, one more time!

umberto-sonnino commented 4 years ago

Hi @tsinis thanks for the support! I've just run our basic example and it seems to be working here..!

Is there some case in particular that's failing for you?

tsinis commented 4 years ago

Hi @tsinis thanks for the support! I've just run our basic example and it seems to be working here..!

Is there some case in particular that's failing for you?

Hey @umberto-sonnino

Thanks for your reply! Sadly, your basic example does not using cachedActor function. I'm talking about that specific case mentoed by @luigi-rosso. It is used in your developer_quest app (i've linked in first message). It have to cache animation in main.dart before app loaded completely, but It does not work anymore. It's also mentoed in your loading strategies, which apparently needs to be updated...

Function does not takes two arguments, but only one "AssetProvider" (since flare_flutter v2+), but there is no much documentation to that. How can we cache our animations on app launch, before first runApp() run?

tsinis commented 4 years ago

Hi @umberto-sonnino!

I'm closing Issue, since I have figured out how to do it. Old way mentoed in documentation, Loading strategies:

const _filesToWarmup = [
  "assets/file.flr",
];

Future<void> warmupFlare() async {
  for (final filename in _filesToWarmup) {
    await cachedActor(rootBundle, filename);
  }
}

New way, since package version 2.0+

import 'package:flare_flutter/asset_provider.dart';
import 'package:flare_flutter/provider/asset_flare.dart';

final AssetProvider assetProvider = AssetFlare(bundle: rootBundle, name: 'assets/file.flr');

Future<void> _warmupAnimations() async {
await cachedActor(assetProvider);
}

Please update documentation. Thanks in advance and see you in Warsaw on Friday!