首页 > 其他 > 详细

animation

时间:2019-06-07 15:04:20      阅读:70      评论:0      收藏:0      [点我收藏+]
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<HomePage> 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: <Widget>[
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();},
),
],
),
);
}
}

animation

原文:https://www.cnblogs.com/braveheart007/p/10988121.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!