zoukankan      html  css  js  c++  java
  • flutter 启动图

    代码:

    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)

     

    }

  • 相关阅读:
    [ZOJ 4062][2018ICPC青岛站][Plants vs. Zombies]
    [Wannafly挑战赛28][B msc和mcc][预处理+枚举]
    [codeforces Mail.Ru Cup 2018 Round 1 D][ xor 操作]
    [codeforces round#475 div2 ][C Alternating Sum ]
    [zoj4045][思维+dfs]
    [zoj4046][树状数组求逆序(强化版)]
    费马大定理以及求解a^2+b^2=c^2的奇偶数列法则
    【HDOJ3567】【预处理bfs+映射+康拓展开hash】
    POJ1279 Art Gallery 多边形的核
    第八周 Leetcode 44. Wildcard Matching 水题 (HARD)
  • 原文地址:https://www.cnblogs.com/pp-pping/p/12202344.html
Copyright © 2011-2022 走看看