-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FlareActor flashing when used with Flutter Hero widget #111
Comments
I think the right way to do this is to load the Flare file in the context of the widget that will host the hero. Then you'd need to use a custom LeafRenderWidget (similar to the FlareActor) which displays the Flare file and shares it across the different LeafRenderWidgets. Flare does use caching internally (and I actually tested your code with a pre-warmed cache with the code below) but the flicker is still there as retrieving the items from cache is also asynchronous: Prewarmed (still flickers) cache: import 'package:flare_flutter/flare_cache.dart';
import 'package:flare_flutter/flare_cache_asset.dart';
import 'package:flutter/services.dart';
// ... leaving out other imports
Future<void> main() async
{
FlareCacheAsset asset1 = await cachedActor(rootBundle, 'assets/Chatbot-back.flr');
asset1.ref();
FlareCacheAsset asset2 = await cachedActor(rootBundle, 'assets/Chatbot-front.flr');
asset2.ref();
runApp(MyApp());
} The right solution is a more involved example, I'll provide you with that as soon as I have a little time to spend on it. |
Alright give this example a try: The two pages share the same Flare artboards and controller for the animation so that they can control the same Flare artboard without reloading and across different widgets. Result is no flickering and better animation control! Notice how the animation gets triggered when the user taps: |
Wow thanks for your reply @luigi-rosso . I wasn't asking for so much, now even the animation is working correctly while the Flare is moving 😃 . Thank you so much. BTW: I first had a "Type" error when building your example.
|
Oh yes, that's related to breaking changes between dev/master and stable (Flutter 1.5.4-hotfix.2). I'd strongly recommend you use the dev/master Flutter channel as there are other fixes in there that are worth having (like aot compiler bugs that will manifest as invisible shapes on certain device architectures with Flare) and also faster loading as we can perform the whole Flare file load in an isolate. |
For those who are trying to implement the same thing and are wondering how to use the new Old way: final asset = await cachedActor(rootBundle, 'assets/file.flr');
asset.ref(); New way: final provider = AssetFlare(bundle: rootBundle, name: 'assets/file.flr');
final asset = await cachedActor(provider);
asset.ref(); |
When using a FlareActor inside a Flutter Hero (to transition the Actor to a new page for example), we see two "flashes". One when the Hero creates a new Actor to make the transition to destination page and once again when creating the Actor on the destination page at the end of the transition.
Video of the issue
It looks like this is due to the loading time when displaying an Actor dynamically.
Tested with Flutter v1.5.4-hotfix.2 & Flare-Flutter 1.5.2 in debug and release modes
Code to replicate (main.dart):
And using the 2 assets :
assets.zip
Do you know any workaround or tricks to display the Actor faster, maybe using some sort of caching ?
The text was updated successfully, but these errors were encountered: