SwiftUI-like declarative animations for Flutter. Zero boilerplate - no controllers, no ticker providers required!
dependencies:
swift_animations: ^1.2.2import 'package:swift_animations/swift_animations.dart';
Container(
width: 100,
height: 100,
color: Colors.blue,
)
.animate()
.fadeIn()
.scale(1.2)
.duration(500.ms).scale(value)- Scale uniformly.scaleX(value)- Scale on X axis.scaleY(value)- Scale on Y axis.rotate(degrees)- Rotate by degrees
.fadeIn()- Fade from 0 to 1.fadeOut()- Fade from 1 to 0.opacity(value)- Custom opacity (0.0 to 1.0)
.slideX(value)- Slide on X axis.slideY(value)- Slide on Y axis.slideInTop()- Slide in from top.slideInBottom()- Slide in from bottom.slideInLeft()- Slide in from left.slideInRight()- Slide in from right
.bounce()- Bounce animation curve.pulse()- Pulse animation curve.fadeInScale(value)- Combined fade and scale
.spring(mass, stiffness, damping, initialVelocity)- Custom spring.springIOS()- iOS-style snappy spring.springGentle()- Gentle spring with smooth bounce.springBouncy()- Bouncy spring with high bounce
.duration(value)- Animation duration (supports500.ms,0.5.s,5.m, orDuration).delay(value)- Animation delay.curve(curve)- Custom animation curve.repeat(reverse: bool)- Infinite repeat.repeatCount(count, reverse: bool)- Repeat specific times.persist()- Keep animation state on rebuild
.sGestureDetector()- Liquid tap effects with spring physicsonPressed- Tap callbackonLongPress- Long press callbackscaleOnPress- Scale amount on tap (default: 1.1)longPressDuration- Long press duration (default: 500ms)autoScaleBySize- Auto-scale based on widget sizestretchSensitivity- Stretch effect sensitivitytranslateSensitivity- Translation sensitivity
Platform-specific navigation animations with a fluent API:
Available Navigation Methods:
swift.push(route)- Push a new routeswift.pushReplacement(route)- Replace current routeswift.pushRoute(route)- Push a route objectswift.pushNamed(routeName)- Push a named routeswift.pushReplacementNamed(routeName)- Replace with named routeswift.pushNamedAndRemoveUntil(routeName, predicate)- Push named route and remove untilswift.pushAndRemoveUntil(route, predicate)- Push route and remove until
Configuration:
.ios()- Use iOS-style slide transition (from right).android()- Use Android-style fade + slide up transition.web()- Use web-style fade transition.duration(milliseconds)- Animation duration (int or Duration).curve(curve)- Animation curve (e.g.,Curves.easeInOut).go(context)- Execute navigation
Container(
width: 100,
height: 100,
color: Colors.blue,
)
.animate()
.fadeIn()
.scale(1.5)Container(
width: 100,
height: 100,
color: Colors.purple,
)
.animate()
.fadeIn()
.springIOS()Container(
width: 100,
height: 100,
color: Colors.blue,
)
.sGestureDetector(
onPressed: () => print('Tapped'),
onLongPress: () => print('Long pressed'),
)Container(
width: 120,
height: 120,
decoration: BoxDecoration(
color: Colors.purple,
borderRadius: BorderRadius.circular(20),
),
)
.animate()
.fadeIn()
.scale(1.2)
.slideInBottom()
.rotate(180)
.duration(1.5.s)
.curve(Curves.easeInOut)
.repeat(reverse: true).animate().duration(500.ms) // 500 milliseconds
.animate().duration(0.5.s) // 0.5 seconds
.animate().duration(5.m) // 5 minutes
.animate().duration(".500ms") // String format// iOS-style navigation
swift.push(NextPage())
.ios()
.duration(500)
.curve(Curves.easeInOut)
.go(context);
// Android-style navigation
swift.push(NextPage())
.android()
.duration(500)
.curve(Curves.easeInOut)
.go(context);swift.pushReplacement(HomePage())
.ios()
.duration(300)
.go(context);swift.pushNamed('/details')
.android()
.duration(400)
.curve(Curves.easeOut)
.go(context, arguments: {'id': 123});swift.pushAndRemoveUntil(HomePage(), (route) => false)
.ios()
.duration(500)
.go(context);swift.pushNamedAndRemoveUntil('/home', (route) => false)
.android()
.duration(400)
.go(context);swift.pushReplacementNamed('/login')
.ios()
.duration(300)
.go(context, result: 'logged_out');- ✅ No mixins needed - Just use
StatefulWidgetorStatelessWidget - ✅ Zero boilerplate - No controller setup or disposal
- ✅ Clean API - Simple chaining like SwiftUI
- ✅ Automatic management - All ticker providers handled internally
- ✅ Visibility-based - Animations start when widgets come into view
- ✅ Scroll-aware - Automatically detects scrolling
- ✅ All platforms - Works on iOS, Android, Web, macOS, Linux, Windows
Love using Swift Animations? Your support helps me create more amazing plugins, add new features, and keep improving the developer experience!
Your contributions enable me to:
- 🚀 Build more Flutter plugins and packages
- ✨ Add exciting new features and improvements
- 🐛 Fix bugs faster and maintain high quality
- 📚 Create better documentation and examples
- 💡 Explore innovative ideas for the Flutter ecosystem
Every contribution, big or small, makes a difference! Thank you for supporting open-source development! 🙏
MIT License