D
AnimationsHard50 XP4 min read

What are physics-based animations in Flutter?

TL;DR: Physics-based animations use simulations (SpringSimulation, GravitySimulation, FrictionSimulation) instead of a fixed duration. The animation's velocity and position evolve based on physical laws, giving natural-feeling motion.

Full Answer

Duration-based animations always take the same time regardless of distance. Physics simulations adapt — a spring snaps back quickly if barely displaced, but takes longer if stretched far.

Key Classes

  • SpringSimulation: Bounce/overshoot (stiffness, damping, mass)
  • FrictionSimulation: Gradually decelerates (used in scroll fling)
  • GravitySimulation: Constant acceleration downward
  • AnimationController.animateWith(simulation): Drives controller with physics
🎯

Flutter's ScrollView uses FrictionSimulation under the hood for momentum scrolling. SpringDescription.withDampingRatio lets you tune spring feel without manual stiffness/damping math.

Code Examples

dartSpring simulation on drag release
Output
// Dragged item springs back to center with natural overshoot

Common Mistakes

  • Using fixed-duration animations for gestures — velocity from the gesture should carry into the animation
  • Overly stiff springs (stiffness > 500) that feel jittery

Interview Tip

💡

Interviewers love this topic because most developers never reach for physics APIs. Knowing SpringDescription.withDampingRatio(ratio: 0.5) shows you've done real polish work.

#spring-simulation#physics#scroll-simulation#fling