Animated Button Glow Effect Package π
A beautiful and customizable Flutter package for creating animated buttons with stunning glow effects, perfect for modern applications across all platforms.
β¨ Features
- π¨ Multiple Animation Types: Glow, Scale, Ripple, and Breathing animations
- π Customizable Colors: Set button colors, glow colors, and gradients
- π Flexible Sizing: Support for circular and rectangular buttons with custom dimensions
- β‘ Smooth Animations: Highly optimized animations with customizable duration
- π― Easy Integration: Simple API with sensible defaults
- π§ Highly Customizable: Control every aspect of the button appearance and behavior
- π± Full Cross Platform: Works on iOS, Android, Windows, macOS, Linux, and Web
π Platform Support
Platform | Status | Notes |
---|---|---|
π± Android | β Full Support | All features available |
π iOS | β Full Support | All features available |
π₯οΈ Windows | β Full Support | All features available |
π§ Linux | β Full Support | All features available |
π» macOS | β Full Support | All features available |
π Web | β Full Support | All features available |
π¬ Animation Types
Type | Description | Best For |
---|---|---|
glow |
Simple pulsing glow effect | General purpose buttons |
glowWithScale |
Glow combined with scale animation | Call-to-action buttons |
rippleGlow |
Ripple effect with expanding glow | Interactive elements |
breathingGlow |
Gentle breathing-like animation | Ambient/background buttons |
π Getting Started
Installation
Add this to your package's pubspec.yaml
file:
dependencies:
animated_button_glow_effect: ^1.0.0
Import
import 'package:animated_button_glow_effect/animated_button.dart';
π Usage
Basic Circular Button (Like Your Image)
AnimatedButton.circular(
child: Icon(
Icons.arrow_forward,
color: Colors.white,
size: 24,
),
onPressed: () {
print('Button pressed!');
},
color: Colors.green,
size: 60.0,
glowIntensity: 0.8,
)
Custom Animated Button
AnimatedButton(
child: Text(
'Tap Me!',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
onPressed: () {
// Handle button press
},
color: Colors.blue,
animationType: ButtonAnimationType.glowWithScale,
width: 120,
height: 50,
borderRadius: 25,
glowIntensity: 0.7,
animationDuration: Duration(milliseconds: 1200),
)
Rectangular Button with Gradient
AnimatedButton.rectangular(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.download, color: Colors.white),
SizedBox(width: 8),
Text('Download', style: TextStyle(color: Colors.white)),
],
),
onPressed: () {
// Handle download
},
gradient: LinearGradient(
colors: [Colors.purple, Colors.blue],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
width: 140,
height: 50,
)
ποΈ Customization Options
AnimatedButton Properties
Property | Type | Default | Description |
---|---|---|---|
child |
Widget |
required | Widget to display inside the button |
onPressed |
VoidCallback? |
required | Callback when button is pressed |
color |
Color |
Colors.green |
Primary button color |
glowColor |
Color? |
null |
Custom glow color (defaults to button color) |
width |
double? |
null |
Button width (uses size if null) |
height |
double? |
null |
Button height (uses size if null) |
size |
double |
60.0 |
Button size for circular buttons |
glowIntensity |
double |
0.6 |
Glow effect intensity (0.0 to 1.0) |
animationDuration |
Duration? |
null |
Custom animation duration |
animationType |
ButtonAnimationType |
glow |
Type of animation effect |
repeatAnimation |
bool |
true |
Whether to repeat the animation |
borderRadius |
double |
30.0 |
Border radius of the button |
enableScaleAnimation |
bool |
true |
Enable scale effect on press |
elevation |
double |
4.0 |
Button shadow elevation |
gradient |
Gradient? |
null |
Custom gradient background |
enabled |
bool |
true |
Whether the button is enabled |
padding |
EdgeInsetsGeometry? |
null |
Internal padding |
margin |
EdgeInsetsGeometry? |
null |
External margin |
Factory Constructors
AnimatedButton.circular()
Perfect for creating circular buttons like in your image:
- Automatically sets circular shape
- Uses
breathingGlow
animation by default - Optimized for icon buttons
AnimatedButton.rectangular()
Ideal for rectangular buttons:
- Uses
glowWithScale
animation by default - Perfect for text and icon combinations
- Customizable width and height
π¨ Examples
Different Animation Types
// Simple glow
AnimatedButton(
child: Text('Glow'),
onPressed: () {},
animationType: ButtonAnimationType.glow,
)
// Glow with scale
AnimatedButton(
child: Text('Scale'),
onPressed: () {},
animationType: ButtonAnimationType.glowWithScale,
)
// Ripple effect
AnimatedButton(
child: Text('Ripple'),
onPressed: () {},
animationType: ButtonAnimationType.rippleGlow,
)
// Breathing effect
AnimatedButton(
child: Text('Breathing'),
onPressed: () {},
animationType: ButtonAnimationType.breathingGlow,
)
Custom Colors and Glow
AnimatedButton.circular(
child: Icon(Icons.favorite, color: Colors.white),
onPressed: () {},
color: Colors.red,
glowColor: Colors.pink,
glowIntensity: 0.9,
size: 70.0,
)
Disabled Button
AnimatedButton.circular(
child: Icon(Icons.lock, color: Colors.white54),
onPressed: null, // Set to null to disable
color: Colors.grey,
enabled: false,
)
π― Best Practices
- Glow Intensity: Keep between 0.5-0.8 for optimal visual appeal
- Animation Duration: 1000-2000ms works well for most use cases
- Button Size: Minimum 44x44 points for touch accessibility
- Color Contrast: Ensure sufficient contrast for accessibility
- Performance: Use
repeatAnimation: false
for better performance if continuous animation isn't needed
π§ Advanced Usage
Custom Animation Control
class CustomButtonWidget extends StatefulWidget {
@override
_CustomButtonWidgetState createState() => _CustomButtonWidgetState();
}
class _CustomButtonWidgetState extends State<CustomButtonWidget> {
bool _isAnimating = true;
@override
Widget build(BuildContext context) {
return AnimatedButton(
child: Text('Toggle Animation'),
onPressed: () {
setState(() {
_isAnimating = !_isAnimating;
});
},
repeatAnimation: _isAnimating,
color: Colors.blue,
);
}
}
Responsive Button Sizes
Widget buildResponsiveButton(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final buttonSize = screenWidth > 600 ? 80.0 : 60.0;
return AnimatedButton.circular(
child: Icon(Icons.play_arrow, color: Colors.white),
onPressed: () {},
size: buttonSize,
color: Colors.green,
);
}
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Support
If you like this package, please give it a β on GitHub!
For issues and feature requests, please use the GitHub Issues page.
Made with β€οΈ for the Flutter community