import 'package:flutter/material.dart';
class transitionDemo extends StatefulWidget {
@override
_transitionDemoState createState() => _transitionDemoState();
}
class _transitionDemoState extends State<transitionDemo> {
@override
void initState() {
super.initState();
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
@override
Widget build(BuildContext context) {
return SlideDemo();
}
}
//位置
class SlideDemo extends StatefulWidget {
@override
_slideDemoState createState() => _slideDemoState();
}
class _slideDemoState extends State<SlideDemo>
with SingleTickerProviderStateMixin {
AnimationController _controller;
@override
void initState() {
_controller =
AnimationController(duration: Duration(seconds: 4), vsync: this)
..repeat(reverse: true);
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final Animation opacityAnimation = Tween(begin:0.0,end: 0.8).animate(_controller);//第一种写法
final Animation containerAnimation=Tween(begin: 200.0,end: 400.0).animate(_controller);
return Material(
child: Center(
child: AnimatedBuilder(
animation: _controller,
builder: (context,child){
return Container(
height: 400,
width: 400,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: RadialGradient(//主要代码
colors: [Colors.blue[600],Colors.blue[100]],
stops: [_controller.value,_controller.value+0.1]
)
),
);
}
)
)
);
}
}
Flutter 478呼吸动画01
最新推荐文章于 2024-04-10 00:15:56 发布