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

Add a spring-simulated variant #2

Open
timcreatedit opened this issue Jan 13, 2025 · 3 comments · May be fixed by #3
Open

Add a spring-simulated variant #2

timcreatedit opened this issue Jan 13, 2025 · 3 comments · May be fixed by #3

Comments

@timcreatedit
Copy link

I would love to have a variant of the widget that is animated using spring simulations instead of curves.

This would allow the animations to redirect very smoothly when the position changes during the animation.

I could give this a shot, but I would solve it by adding a dependency to (my own) springsterpackage. Would you be interested in that?

https://pub.dev/packages/springster

@chooyan-eng
Copy link
Owner

@timcreatedit Thank you for your suggestion! And yeah, adding spring simulations has been one of the biggest challenges for this package, which @lukepighetti also suggested on X here.

To be honest, I have no knowledge about physics, so let me start by checking your springster package first.

@chooyan-eng
Copy link
Owner

@timcreatedit I've briefly checked your springster package. It seems SpringSimulationController and SpringSimulationController2D make Flutter's SpringSimulation easily available, and they will equip animated_to with a spring-simulated version of AnimatedTo, maybe AnimatedTo.spring() like below.

/// this internally creates spring-simulated version of `RenderAnimatedTo` 
/// which uses `SpringSimulationController` or `SpringSimulationController2D` depending on the given [spring].
AnimatedTo.spring(
  globalKey: _key,
  spring: SimpleSpring.bouncy,
  child: AnyWidget(),
),

I'm still not sure my idea works well, so I'll try to implement this later.

@timcreatedit
Copy link
Author

I would also gladly contribute this, if you want me to

@timcreatedit timcreatedit linked a pull request Jan 22, 2025 that will close this issue
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 a pull request may close this issue.

2 participants