Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/animation.dart';
  3.  
  4. void main() => runApp(MyApp());
  5.  
  6. class MyApp extends StatefulWidget {
  7. @override
  8. MyAppState createState() => MyAppState();
  9. }
  10.  
  11. class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
  12. Animation animation;
  13. AnimationController animationController;
  14.  
  15. @override
  16. void initState() {
  17. super.initState();
  18. animationController = AnimationController(
  19. duration: Duration(milliseconds: 2000), vsync: this);
  20.  
  21. animation = Tween(begin: 0.0, end: 400.0).animate(animationController);
  22. animation.addStatusListener((status) {
  23. if (status == AnimationStatus.completed) {
  24. animationController.reverse();
  25. } else if (status == AnimationStatus.dismissed) {
  26. animationController.forward();
  27. }
  28. });
  29. animationController.forward();
  30. }
  31.  
  32. @override
  33. Widget build(BuildContext context) {
  34. return LogoAnimation(
  35. animation: animation,
  36. );
  37. }
  38.  
  39. @override
  40. void dispose() {
  41. animationController.dispose();
  42. super.dispose();
  43. }
  44. }
  45.  
  46. class LogoAnimation extends AnimatedWidget {
  47. LogoAnimation({Key key, Animation animation})
  48. : super(key: key, listenable: animation);
  49.  
  50. @override
  51. Widget build(BuildContext context) {
  52. Animation animation = listenable;
  53. return Center(
  54. child: Container(
  55. height: animation.value,
  56. width: animation.value,
  57. child: FlutterLogo(),
  58. ),
  59. );
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement