AnimationComponent that can be customized with modifiers and used with withAnimation.
Animation Types
Spring
Creates a spring-based animation with natural, physics-based motion.response(optional) - The stiffness of the spring (higher = faster). Default varies by platform.dampingFraction(optional) - The amount of damping (0 = no damping, 1 = critical damping). Default is typically 1.blendDuration(optional) - Duration in seconds to blend with other animations. Default is 0.
InterpolatingSpring
Creates a spring animation with explicit physics parameters for precise control over spring behavior.stiffness(required) - The spring constant (higher = stiffer spring)damping(required) - The damping coefficient (higher = more resistance)mass(required) - The mass being animated (higher = slower to move)
EaseIn
Creates an animation that starts slowly and accelerates toward the end.duration(optional) - Animation duration in seconds. Default is typically 0.35.
EaseOut
Creates an animation that starts quickly and decelerates toward the end.duration(optional) - Animation duration in seconds. Default is typically 0.35.
EaseInOut
Creates an animation that starts slowly, accelerates in the middle, and decelerates at the end.duration(optional) - Animation duration in seconds. Default is typically 0.35.
Linear
Creates an animation with constant velocity throughout.duration(optional) - Animation duration in seconds. Default is typically 0.35.
Bouncy
Creates a playful spring animation with extra bounce.duration(optional) - The approximate duration in seconds. Default varies by platform.extraBounce(optional) - Amount of additional bounce (0 = no extra bounce, 1 = maximum bounce). Default is 0.
Snappy
Creates a quick, responsive spring animation.response(optional) - The stiffness of the spring (higher = faster). Default varies by platform.dampingFraction(optional) - The amount of damping (0 = no damping, 1 = critical damping). Default is typically 1.blendDuration(optional) - Duration in seconds to blend with other animations. Default is 0.
Animation Modifiers
All animation components support these modifier methods that can be chained together:delay
Delays the start of the animation.speed
Adjusts the speed of the animation (multiplier).repeatCount
Repeats the animation a specific number of times.repeatForever
Repeats the animation indefinitely.autoreverses- If true, the animation reverses direction each time it completes
Combining Modifiers
Modifiers can be chained together for complex animation behaviors:Complete Examples
Loading Spinner
Pulsing Heart
Staggered List Animation
Interactive Gesture Animation
Animation Best Practices
-
Choose the Right Animation Type:
- Use
SpringorSnappyfor interactive, gesture-driven animations - Use
EaseInOutfor general transitions - Use
Linearfor continuous motion like loaders - Use
Bouncyfor playful, attention-grabbing effects
- Use
-
Duration Guidelines:
- Quick interactions: 0.2-0.3 seconds
- Standard transitions: 0.3-0.5 seconds
- Dramatic effects: 0.5-1.0 seconds
- Avoid durations over 1.5 seconds unless necessary
-
Performance Considerations:
- Animate transform properties (scale, rotation, offset) for best performance
- Avoid animating layout properties when possible
- Use
repeatForeversparingly to prevent performance issues - Consider reducing animation complexity on lower-end devices
-
Accessibility:
- Respect user preferences for reduced motion
- Provide alternative feedback for users who disable animations
- Keep critical animations brief and purposeful
Notes
- Animation behavior may vary slightly between platforms (web, iOS, Android)
- Default parameter values are platform-specific and optimized for each environment
- Animations created with these functions work seamlessly with
withAnimation - Multiple animations on the same property will use the most recently applied animation
- Spring animations may overshoot their target based on damping settings
