Skip to content
/ sprung Public
forked from lukepighetti/sprung

Drive realistic animations in Flutter with real physics

License

Notifications You must be signed in to change notification settings

edeuss/sprung

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sprung

Sprung is an easy-to-consume Curve that uses real physics equations to drive your animations.

Easy to consume

AnimatedContainer(
  /// Critically damped by default
  curve: Sprung(),
  /// ...
),
AnimatedContainer(
  /// Easily adjust damping value
  curve: Sprung(16),
  /// ...
),
AnimatedContainer(
  /// Build a custom spring
  curve: Sprung(
    damping: 20,
    stiffness: 180,
    mass: 1.0,
  ),
  /// ...
),

Sprung has three opinionated curves, Sprung.underDamped, Sprung.criticallyDamped, and Sprung.overDamped.

AnimatedContainer(
  curve: Sprung.underDamped,
  /// ...
),

Based on Physics

Using Flutter's physics engine which leverages Newton's Second Law of Motion, Hooke's Law, and velocity based damping, we implement the following equation to create realistic spring animations.

m times x dot dot equals negative k times parenthesis x minus 1 close parenthesis minus c times x dot

Believable motion

demo of under, critically, and over damped Flutter curves

Reliable accuracy

Sprung exceeds Flutter specifications for curves by guaranteeing an error less than 1e-6. This amounts to a 0.0019px jitter at the beginning or end of a 1920px move.

About

Drive realistic animations in Flutter with real physics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 74.3%
  • Shell 7.8%
  • Ruby 7.2%
  • Objective-C 7.2%
  • Java 3.5%