Skip to content
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

Loop animation, wait until it finish a lap to start another one #62

Closed
jaumard opened this issue Mar 25, 2019 · 6 comments
Closed

Loop animation, wait until it finish a lap to start another one #62

jaumard opened this issue Mar 25, 2019 · 6 comments

Comments

@jaumard
Copy link

jaumard commented Mar 25, 2019

Hey :) I'm having trouble implementing a feature for flutter_splash_screen, my idea was to make a loop animation idle until the initialization of the app is done, then switch to a "finish animation" before pushing the next screen. Problem is that the callback is not called for a loop animation, so I do know when a lap is finished to chain the second animation in a smooth way.

I guess my only way is the FlareController, do you have some code somewhere that does similar things ?

In any way I think it will be nice to have a finishedCallback and a loopCallback, will be very handy :) or at least that the callback is called on each lap

@jaumard jaumard changed the title Loop animation, wait until it finish to start another one Loop animation, wait until it finish a lap to start another one Mar 25, 2019
@asjqkkkk
Copy link

FlareActor has a FlareCompletedCallback, But this is only valid in non-loop animations.

just like

new FlareActor(
                  "xxx.flr",
                  fit: BoxFit.scaleDown,
                  animation: animation,
                  callback: (name) {
                    if (name == "animation_one") {
                      ...
                    } else if (name == "animation_two") {
                      ...
                    } else if (name == "animation_three") {
                      ...
                    }
                  },
                )

But i don't kown how to use FlareController,I hope the official has a simpler example than bear animation

@luigi-rosso
Copy link
Contributor

We can definitely introduce a callback for the loop, but yes the FlareController might be a better way to go for now. There are a few examples of FlareControllers in the example folder here (the penguin uses it and so does the space_reload).

Have you tried simply swapping to your "finish animation" regardless of where the "idle" animation is? This should work as we have a 0.2 second mix value currently hardcoded into FlareActor. That means it'll smoothly interpolate the two animations.

In the meantime I'll cook up a sample controller, just need to finish a few things but I should be able to get it to you later tonight.

@asjqkkkk
Copy link

Thank you very much, I really like flare ^_^

@luigi-rosso
Copy link
Contributor

Alright I put together a simple example here:
https://github.com/luigi-rosso/sequenced_loader

Controller and widget code are coupled together as it was pretty self contained, might be nice to split them up if you want to support other flare files/layouts/etc.
https://github.com/luigi-rosso/sequenced_loader/blob/master/lib/flare_progress_indicator.dart

Flare file is here:
https://www.2dimensions.com/a/castor/files/flare/sequencedloader

@jaumard
Copy link
Author

jaumard commented Mar 26, 2019

Works really nicely @luigi-rosso ! Thanks a lot ! I'll integrate this into flare_spalsh_screen :) it will help me understand better FlareController as for now it's still obscur to me ^^

@jaumard
Copy link
Author

jaumard commented Mar 26, 2019

flare_splash_screen has been updated to use this ! I also customize it a bit to be able to do intro, loop, complete animation with all animation optional to be able to mix whatever combination we need/want.

I was thinking ok it's great for a splash screen but it can be use for all sort of loading widget in fact ! So I created flare_loading https://github.com/jaumard/flare_loading that offer the same capabilities but that you can use for all kind of loading process.

Thanks a lot for the help @luigi-rosso !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants