zoukankan      html  css  js  c++  java
  • flutter 动画

    1. App闪屏动画(应用进入界面广告)案例:

    import 'package:flutter/material.dart';
    import 'home_page.dart';    // MyHomePage()
    
    class SplashScreen extends StatefulWidget {
      @override
      _SplashScreenState createState() => _SplashScreenState();
    }
    
    // 混入
    class _SplashScreenState extends State<SplashScreen>
        with SingleTickerProviderStateMixin {
      // 动画控制器
      AnimationController _container;
      Animation _animation;
    
      @override
      void initState() {
        super.initState();
        _container = AnimationController(
            vsync: this, duration: Duration(milliseconds: 3000));
        _animation = Tween(begin: 0.0, end: 1.0).animate(_container);
    
        _animation.addStatusListener((status) {
          if (status == AnimationStatus.completed) {
            Navigator.of(context).pushAndRemoveUntil(
              MaterialPageRoute(builder: (cintext) => MyHomePage()), // 显示完后跳转到首页
              (route) => route == null,
            );
          }
        });
    
        _container.forward(); // 播放动画
      }
    
      @override
      void dispose() {
        _container.dispose(); // 销毁控制器
        super.dispose();
      }
    
      @override
      Widget build(BuildContext context) {
        return FadeTransition(
          opacity: _animation,
          child: Image.network(
            'http://hbimg.b0.upaiyun.com/615efb61cbc8ec8aad8febdf5a74541fb79c54862658a-mPdqeZ_fw658',
            scale: 2.0,
            fit: BoxFit.cover,
          ),
        );
      }
    }
    部分代码实现
  • 相关阅读:
    ubuntu16.04解决播放swf视频文件问题
    ubuntu下设置clion是使用clang和clang++
    Linux 下没有conio.h 已解决
    适合最新版docker自定义启动配置
    nginx限制ip并发数
    nginx 403错误
    ubuntu 支持中文
    CentOS 5 上使用yum同时安装32位和64位包的解决方法
    rhel yum报错
    因为swap分区无法启动
  • 原文地址:https://www.cnblogs.com/cap-rq/p/12778917.html
Copyright © 2011-2022 走看看