import 'package:flutter/material.dart';
class ExampleAnimation extends StatefulWidget {
@override
_ExampleAnimationState createState() => _ExampleAnimationState();
}
class _ExampleAnimationState extends State<ExampleAnimation>
with SingleTickerProviderStateMixin {
AnimationController _animationController;
Animation<double> _animation;
@override
void initState() {
super.initState();
_animationController = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
);
_animation = Tween<double>(
begin: 0,
end: 1,
).animate(_animationController);
_animationController.forward();
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter Animation Example'),
),
body: Center(
child: FadeTransition(
opacity: _animation,
child: FlutterLogo(
size: 200,
),
),
),
);
}
}
void main() {
runApp(MaterialApp(
home: ExampleAnimation(),
));
}