Skip to main content

AnimatedBoxAppi

A customizable animated box widget that provides smooth transitions between different states with hover effects and animations.

Features

  • Smooth Animations: Configurable animation duration with easing curves
  • Hover Effects: Interactive hover states with customizable properties
  • Flexible Styling: Support for colors, borders, elevation, and decorations
  • Touch Support: Tap and hover event handling
  • Customizable Child: Dynamic child content based on hover state

Usage

AnimatedBoxAppi(
fromHeight: 100,
toHeight: 120,
fromWidth: 200,
toWidth: 220,
fromColor: Colors.blue,
toColor: Colors.blueAccent,
animationDuration: Duration(milliseconds: 300),
ontap: () {
print('Box tapped!');
},
child: (hovered) => Container(
child: Text(
hovered ? 'Hovered!' : 'Normal',
style: TextStyle(color: Colors.white),
),
),
)

Parameters

ParameterTypeDescription
childdynamicRequired. Function that returns widget content, receives hovered boolean
fromHeightdoubleRequired. Initial height of the box
animationDurationDuration?Animation duration (default: 600ms)
toHeightdouble?Height when hovered (defaults to fromHeight)
fromWidthdouble?Initial width of the box
toWidthdouble?Width when hovered (defaults to fromWidth)
fromRadiusdouble?Initial border radius
toRadiusdouble?Border radius when hovered
fromColorColor?Initial background color
toColorColor?Background color when hovered
fromElevationdouble?Initial elevation
toElevationdouble?Elevation when hovered
ontapFunction?Callback function when box is tapped
onHoveredFunction?Callback function when box is hovered
decorationImgDecorationImage?Background decoration image
borderColorColor?Border color
borderWidthdouble?Border width
borderRadiusdouble?Container border radius
childFromColorColor?Child color in normal state
childToColorColor?Child color when hovered

Examples

Basic Animated Box

AnimatedBoxAppi(
fromHeight: 80,
toHeight: 100,
fromColor: Colors.grey[300],
toColor: Colors.blue,
child: (hovered) => Center(
child: Icon(
Icons.star,
color: hovered ? Colors.white : Colors.grey[600],
),
),
ontap: () => print('Star tapped!'),
)

Card with Elevation Animation

AnimatedBoxAppi(
fromHeight: 150,
fromWidth: 200,
fromElevation: 2,
toElevation: 8,
fromRadius: 8,
toRadius: 12,
borderColor: Colors.grey[300],
borderWidth: 1,
child: (hovered) => Padding(
padding: EdgeInsets.all(16),
child: Column(
children: [
Text('Hover me!'),
if (hovered) Icon(Icons.arrow_upward),
],
),
),
)