rotate_album.dart 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import 'package:flutter/material.dart';
  2. class RotateAlbum extends StatefulWidget {
  3. RotateAlbum({Key? key}) : super(key: key);
  4. _RotateAlbumState createState() => _RotateAlbumState();
  5. }
  6. class _RotateAlbumState extends State<RotateAlbum>
  7. with SingleTickerProviderStateMixin {
  8. late AnimationController _controller;
  9. var animation;
  10. @override
  11. void initState() {
  12. super.initState();
  13. _controller =
  14. AnimationController(vsync: this, duration: Duration(seconds: 4));
  15. animation = RotationTransition(
  16. turns: Tween(begin: 0.0, end: 1.0).animate(_controller)
  17. ..addStatusListener((status) {
  18. if (status == AnimationStatus.completed) {
  19. // _controller.forward(from: 0.0);
  20. }
  21. }),
  22. child: Container(
  23. child: CircleAvatar(
  24. backgroundImage: NetworkImage(
  25. "https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D500/sign=dde475320ee9390152028d3e4bec54f9/d009b3de9c82d1586d8294a38f0a19d8bc3e42a4.jpg"),
  26. )),
  27. );
  28. _controller.forward(from: 0.0);
  29. }
  30. @override
  31. void dispose() {
  32. _controller.dispose();
  33. super.dispose();
  34. }
  35. @override
  36. Widget build(BuildContext context) {
  37. return Container(
  38. padding: EdgeInsets.all(18),
  39. child: animation,
  40. );
  41. }
  42. }