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

FEATURE: Choose whether to reset or not a OneShotAnimation #348

Closed
wants to merge 1 commit into from
Closed

FEATURE: Choose whether to reset or not a OneShotAnimation #348

wants to merge 1 commit into from

Conversation

TheFe91
Copy link

@TheFe91 TheFe91 commented Sep 28, 2023

Currently a OneShotAnimation resets the animation to its first frame at his hand. This PR introduces the possibility to disable this behavior.

@HayesGordon
Copy link
Contributor

Hi @TheFe91 thanks for the contribution!

This is something we could add, but this could become bloated really fast by having all the possible lifetime conditions for a controller. An alternative approach (and the suggested) would be to instead extend the desired class and create your own controller. In this instance it could look something like this:

class MyController extends OneShotAnimation {
  MyController(String animationName, {this.resetOnEnd = true})
      : super(animationName);
  final bool resetOnEnd;

  @override
  void reset() {
    if (resetOnEnd) {
      super.reset();
    }
  }
}

Or for more control extend SimpleAnimation

@TheFe91
Copy link
Author

TheFe91 commented Sep 28, 2023

Thank you!
This is exactly what I've been doing till today, so I thought that it could be a nice solution to have that boolean inside that funciton.

And thanks also for the suggestion. I think that at this point there's no need to keep this PR opened!
Cheers!

@TheFe91 TheFe91 closed this Sep 28, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants