Hibok
您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字
 
 
 
 
 
 

47 行
1.1 KiB

  1. import 'package:flutter/material.dart';
  2. import '../r.dart';
  3. class CoinAnim extends StatefulWidget {
  4. @override
  5. _CoinAnimState createState() => _CoinAnimState();
  6. }
  7. class _CoinAnimState extends State<CoinAnim>
  8. with SingleTickerProviderStateMixin {
  9. Animation<double> _animation;
  10. AnimationController _controller;
  11. double begin = 100;
  12. double end = 20;
  13. @override
  14. void initState() {
  15. super.initState();
  16. // 启动动画controller
  17. _controller = new AnimationController(
  18. duration: Duration(milliseconds: 500), vsync: this);
  19. _controller.addStatusListener((AnimationStatus status) {});
  20. _animation = new Tween<double>(begin: begin, end: end).animate(_controller)
  21. ..addListener(() {
  22. setState(() {});
  23. });
  24. _controller.forward(from: begin);
  25. }
  26. @override
  27. void dispose() {
  28. _controller.stop();
  29. _controller.dispose();
  30. super.dispose();
  31. }
  32. @override
  33. Widget build(BuildContext context) {
  34. return Positioned(
  35. child: Container(
  36. height: _animation.value, child: Image.asset(R.assetsImagesCoin)));
  37. }
  38. }