|
- import 'package:flutter/material.dart';
-
- import '../r.dart';
-
- class CoinAnim extends StatefulWidget {
- @override
- _CoinAnimState createState() => _CoinAnimState();
- }
-
- class _CoinAnimState extends State<CoinAnim>
- with SingleTickerProviderStateMixin {
- Animation<double> _animation;
- AnimationController _controller;
- double begin = 100;
- double end = 20;
-
- @override
- void initState() {
- super.initState();
- // 启动动画controller
- _controller = new AnimationController(
- duration: Duration(milliseconds: 500), vsync: this);
- _controller.addStatusListener((AnimationStatus status) {});
-
- _animation = new Tween<double>(begin: begin, end: end).animate(_controller)
- ..addListener(() {
- setState(() {});
- });
-
- _controller.forward(from: begin);
- }
-
- @override
- void dispose() {
- _controller.stop();
- _controller.dispose();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- return Positioned(
- child: Container(
- height: _animation.value, child: Image.asset(R.assetsImagesCoin)));
- }
- }
|