import 'package:flutter/material.dart';
class AnimationDemoScreen extends StatefulWidget {
@override
State<AnimationDemoScreen> createState() => _AnimationDemoScreenState();
}
class _AnimationDemoScreenState extends State<AnimationDemoScreen> {
bool _isLarge = false;
void _toggleSize() {
setState(() {
_isLarge = !_isLarge;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Animation Demo Screen')),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AnimatedContainer(
width: _isLarge ? 200 : 100,
height: _isLarge ? 200 : 100,
color: Colors.blue,
duration: Duration(milliseconds: 500),
curve: Curves.easeInOut,
),
SizedBox(height: 20),
ElevatedButton(
onPressed: _toggleSize,
child: Text('Animate Box'),
),
],
),
),
);
}
}This example uses AnimatedContainer to smoothly change the size of a blue box when the button is pressed. The animation lasts 500 milliseconds and uses an ease-in-out curve for a natural feel.
Animations like this help users see changes clearly and make the app feel alive and responsive. Instead of a sudden jump, the smooth transition guides the eye and improves the experience.