博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
animation
阅读量:4316 次
发布时间:2019-06-06

本文共 2478 字,大约阅读时间需要 8 分钟。

import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget {
@override Widget build(BuildContext context) {
return MaterialApp( home: HomePage(), ); } } class HomePage extends StatefulWidget {
@override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State
with TickerProviderStateMixin {
AnimationController animationController; Animation animation; Animation animationColor; CurvedAnimation curve; @override void initState() {
// TODO: implement initState animationController = AnimationController( vsync: this, //value: 32.0, //lowerBound: 0.0, //upperBound: 200.0, duration: Duration(milliseconds: 5000), ); curve = CurvedAnimation(parent: animationController, curve: Curves.easeInOut); animation = Tween(begin: 32.0, end: 360.0,).animate(curve); animationColor = ColorTween(begin: Colors.red, end: Colors.green,).animate(curve); animationController.addListener(() {
print(animationController.value); setState(() {}); }); animationController.addStatusListener((AnimationStatus status){print(status);}); super.initState(); } @override void dispose() {
// TODO: implement dispose animationController.dispose(); super.dispose(); } @override Widget build(BuildContext context) {
return Scaffold( appBar: AppBar( title: Text(''), ), body: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children:
[ IconButton( icon: Icon(Icons.favorite), color: animationColor.value, iconSize: animation.value, onPressed: () {
animationController.forward(); switch(animationController.status){
case AnimationStatus.completed: animationController.reverse(); break; default: animationController.forward(); } }), SizedBox(height: 57,), RaisedButton( child: Icon(Icons.enhanced_encryption), onPressed: (){animationController.reverse();}, ), ], ), ); } }

转载于:https://www.cnblogs.com/braveheart007/p/10988121.html

你可能感兴趣的文章
Div Vertical Menu ver3
查看>>
Git简明操作
查看>>
InnoDB为什么要使用auto_Increment
查看>>
HDU 1087 Super Jumping! Jumping! Jumping!
查看>>
0007_初始模块和字节码
查看>>
[效率提升]如何管理好你的电脑文件
查看>>
C++实验二
查看>>
使用case语句给字体改变颜色
查看>>
JAVA基础-多线程
查看>>
面试题5:字符串替换空格
查看>>
JSP九大内置对象及四个作用域
查看>>
ConnectionString 属性尚未初始化
查看>>
MySQL基本命令和常用数据库对象
查看>>
poj 1222 EXTENDED LIGHTS OUT(位运算+枚举)
查看>>
进程和线程概念及原理
查看>>
Lucene、ES好文章
查看>>
android 生命周期
查看>>
jquery--this
查看>>
MySQL 5.1参考手册
查看>>
TensorFlow安装流程(GPU加速)
查看>>