From 581dc9fd8b6da998d28d1614bf7ca9f4069fda72 Mon Sep 17 00:00:00 2001 From: ZCM <772112648@qq.com> Date: Mon, 13 Apr 2020 09:00:44 +0800 Subject: [PATCH] 1 --- lib/chat/ChatPage.dart | 2 +- lib/home/coin_anim.dart | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 lib/home/coin_anim.dart diff --git a/lib/chat/ChatPage.dart b/lib/chat/ChatPage.dart index fa00612..d57cf73 100644 --- a/lib/chat/ChatPage.dart +++ b/lib/chat/ChatPage.dart @@ -617,7 +617,7 @@ class _ChatPageState extends State { double zoomButtonSizeHeight = 74; void dragEvent(DragUpdateDetails details) { - final RenderObject box = context.findRenderObject(); + final RenderObject F = context.findRenderObject(); // 获得自定义Widget的大小,用来计算Widget的中心锚点 dx = details.globalPosition.dx - mykey.currentContext.size.width / 2; dy = details.globalPosition.dy - mykey.currentContext.size.height / 2; diff --git a/lib/home/coin_anim.dart b/lib/home/coin_anim.dart new file mode 100644 index 0000000..15fbac3 --- /dev/null +++ b/lib/home/coin_anim.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; + +import '../r.dart'; + +class CoinAnim extends StatefulWidget { + @override + _CoinAnimState createState() => _CoinAnimState(); +} + +class _CoinAnimState extends State + with SingleTickerProviderStateMixin { + Animation _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(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))); + } +}