代码:
   import 'package:flutter/material.dart'; 
 
 
 
   import 'home_test.dart'; 
 
 
 
   class SplashScreen extends StatefulWidget { 
 
 
 
   SplashScreen({Key key}) : super(key: key); 
 
 
 
   @override 
 
 
 
   _SplashScreenState createState() => _SplashScreenState(); 
 
 
 
   } 
 
 
 
   class _SplashScreenState extends State<SplashScreen> with SingleTickerProviderStateMixin{ 
 
 
 
   AnimationController _controller; 
 
 
 
   Animation _animation; 
 
 
 
   @override 
 
 
 
   void initState() { 
 
 
 
   super.initState(); 
 
 
 
   _controller = AnimationController(vsync:this,duration: Duration(milliseconds: 3000));//垂直动态演示 -- 毫秒 
 
 
 
   _animation = Tween(begin: 0.0,end: 1.0).animate(_controller); 
 
 
 
   _animation.addStatusListener((status){//监听 动画状态 
 
 
 
   if (status == AnimationStatus.completed) {//动画结束 
 
 
 
   //路由跳转 
 
 
 
   Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context)=>MyHome()),(route) => route == null );//跳转下一页 并把动画结束 
 
 
 
   } 
 
 
 
   }); 
 
 
 
   _controller.forward();//播放动画 
 
 
 
   } 
 
 
 
   @override 
 
 
 
   void dispose() { 
 
 
 
   super.dispose(); 
 
 
 
   d 
 
 
 
   _controller.dispose();//销毁控制器 
 
 
 
   } 
 
 
 
   @override 
 
 
 
   Widget build(BuildContext context) { 
 
 
 
   return FadeTransition(//动画过渡控件 
 
 
 
   opacity: _animation, 
 
 
 
   child: Image.network('http://img.mp.itc.cn/upload/20170413/bf3c5c6a69264f08b66cabe456c460e1_th.jpg',fit: BoxFit.cover,scale: 2.0), 
 
 
 
   ); 
 
 
 
   } 
 
 
 
   } 
 
 
  总结: 
 
 
//启动图 —— 有点类似于我们的广告到首页
1.继承SingleTickerProviderStateMixin
2.声明两个变量 AnimationController 和 Animation
重写state
初始化
2.1 _animitionController = AnimationController(vsync:this,Duration(xx));;//垂直动态演示 和 时间
2.2 _ animation = Animation(Tween(begin:0,end:1).animate(_animationController)
_animation.addStatusListener(status)//监听状态
If(status == AnimationStatus.completed){
//动画结束
//路由跳转到下一页 并把当前动画结束 因为很耗资源
Navigator.of(context).pushAndRemoveUtil(MaterialPageRoute(build:(context)=>CCC()),(route)=>route == null)
}
