Overview
Wonderous leverages the powerfulflutter_animate package (v4.5.0) to create smooth, expressive animations throughout the app. The animation system is designed with performance in mind and includes built-in support for disabling animations for accessibility.
Flutter Animate Integration
The app uses flutter_animate as its primary animation framework (pubspec.yaml:26):
common_libs.dart:11:
Animation Durations
Standardized timing values ensure consistent motion (lib/styles/styles.dart:197-204):
$styles.times.med
Duration Extensions
Custom extensions provide millisecond shortcuts (lib/ui/common/utils/duration_utils.dart:3-6):
delayMs returns 0.ms and animateMs returns 1.ms to prevent delays while maintaining animation structure.
Animation Control
Disable Animations
The app supports disabling animations for accessibility (lib/styles/styles.dart:10,28):
- All duration values (via
DurationExtensions) - The
maybeAnimate()extension - Animation playback throughout the app
MaybeAnimate Extension
Conditional animation wrapper (lib/logic/common/animate_utils.dart:16-45):
disableAnimations is true, the NeverAnimate widget simply returns the child without animation overhead.
Common Animation Patterns
Fade In
Fade with Delay
Slide Transition
Shimmer Effect
Used for collectible items to draw attention:Swap Transition
Cross-fade between widgets:Custom Animation Effects
Custom Tweens
Wonderous implements custom animation effects usingCustomEffect (lib/ui/screens/home/widgets/_animated_arrow_button.dart:11-54):
- Fades to transparent
- Jumps to a new position (hidden)
- Slides back up while fading in
Toggle Animations
Conditional animations based on state:Performance Optimizations
Impeller Rendering
Wonderous uses Flutter’s new Impeller rendering engine on iOS (README.md:39-41):
- Predictable performance (no shader compilation jank)
- Smoother animations
- Better GPU utilization
- Reduced frame drops
Animation Optimization Strategies
1. Conditional Rendering
Only animate when visible:2. RepaintBoundary
Isolate expensive animations:3. Const Constructors
Use const for static animation parameters:4. Animation Keys
Prevent unnecessary rebuilds:5. Controller Reuse
Share controllers when animating multiple related widgets:Built-in Effects
Flutter Animate provides numerous effects used throughout Wonderous:Visual Effects
- FadeEffect - Opacity transitions
- SlideEffect - Position changes
- ScaleEffect - Size transformations
- ShimmerEffect - Glossy highlight sweep
- ShakeEffect - Vibration/wiggle
- BlurEffect - Gaussian blur in/out
- TintEffect - Color overlay
Composite Effects
Chain multiple effects:Animation Examples from Wonderous
Collectible Discovery
Complex animation sequence when discovering artifacts:Page Transitions
Smooth transitions between screens:Timeline Events
Staggered entrance animations:Best Practices
1. Use Semantic Durations
Prefer named durations over magic numbers:2. Respect Accessibility
Always usemaybeAnimate() instead of Animate() directly:
3. Chain Thoughtfully
Excessive animation can be distracting:4. Match Platform Conventions
Use platform-appropriate curves:5. Test Performance
Monitor frame rates during animation:Debugging Animations
Enable Slow Animations
Visual Debugging
Flutter DevTools provides:- Performance overlay
- Repaint rainbow
- Timeline profiler
- Widget inspector