更多代码参考

有短暂的白屏时间

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: '启动图demo',
debugShowCheckedModeBanner: false,
home: AnimatedSplashScreen(
home: HomePage(),
),
);
}
} class AnimatedSplashScreen extends StatefulWidget {
final Widget home; const AnimatedSplashScreen({Key key, @required this.home}) : super(key: key);
@override
SplashScreenState createState() => new SplashScreenState();
} class SplashScreenState extends State<AnimatedSplashScreen>
with SingleTickerProviderStateMixin {
AnimationController animationController;
Animation<double> animation;
Duration keepTimer = Duration(seconds: 3);
int get showSecond => keepTimer.inSeconds;
Timer timer;
bool isSkip = false; startTime() async {
await Future.delayed(keepTimer);
_toHome();
} _toHome() {
if (isSkip) return;
isSkip = true;
Navigator.of(context)
.pushReplacement(MaterialPageRoute(builder: (context) => widget.home));
} @override
void initState() {
super.initState();
animationController =
AnimationController(vsync: this, duration: Duration(seconds: 2));
animation =
CurvedAnimation(parent: animationController, curve: Curves.easeOut); animation.addListener(() => this.setState(() {}));
animationController.forward();
// startTime();
Duration step = Duration(seconds: 1);
timer = Timer.periodic(Duration(seconds: 1), (_) {
setState(() {
keepTimer -= step;
});
if (keepTimer == Duration.zero) {
timer.cancel();
}
});
} @override
void dispose() {
animationController?.dispose();
timer?.cancel();
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
super.dispose();
} @override
Widget build(BuildContext context) {
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: <Widget>[
Positioned(
right: 10,
bottom: 50,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
color: Colors.grey[300],
textColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
onPressed: _toHome,
child: Text('跳过 $showSecond'),
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: EdgeInsets.only(bottom: 30.0),
child: Image.asset(
'assets/images/powered_by.png',
height: 25.0,
fit: BoxFit.scaleDown,
))
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'assets/images/logo.png',
width: animation.value * 250,
height: animation.value * 250,
),
],
),
],
),
);
}
} class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
} class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Home'),
),
body: Center(
child: RaisedButton(
child: Text('data'),
onPressed: () async {},
),
),
);
}
}

配置xml

λ flutter --version
Flutter 1.12.17-pre.61 • channel master • https://github.com/flutter/flutter.git
Framework • revision 1c7a1c3873 (4 hours ago) • 2019-12-04 07:51:54 +0100
Engine • revision 3e6d6bc612
Tools • Dart 2.7.0 (build 2.7.0-dev.2.1 19fc1016da)
  1. 添加启动图 android\app\src\main\res\drawable\bg.png

  2. 修改android\app\src\main\res\drawable\launch_background.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/holo_blue_light" /> <!-- You can insert your own image assets here 删除下面的注释 -->
<item>
<bitmap
android:gravity="center"
android:src="@drawable/bg" />
</item>
</layer-list>

Flutter: 设置简单的启动屏的更多相关文章

  1. iOS 实现启动屏动画(Swift实现,包含图片适配)

    代码地址如下:http://www.demodashi.com/demo/12090.html 准备工作 首先我们需要确定作为宣传的图片的宽高比,这个一般是与 UI 确定的.一般启动屏展示会有上下两部 ...

  2. React Native(ios)项目中logo,启动屏设置

    由于logo和启动屏尺寸多,react native(ios)中没有命令可以自动生成各种的尺寸,所以可以使用以下办法:在ionic项目中生成(使用命令:ionic resources)后,再粘贴到re ...

  3. Ios8 Xcode6 设置Launch Image 启动图片

    http://blog.sina.com.cn/s/blog_6c97abf10102voui.html Http://Www.woowen.com/Swift/2014/12/12/Ios8设置La ...

  4. android 决解启动屏白黑屏会延迟几秒的问题

    通常写启动屏,都有个很不喜欢的问题,就是会空白几秒才显示界面,而且界面还是很简单的! 解决办法 1 写一个透明的主题,一般启动屏都是不要bar的所以继承AppTheme.NoActionBar < ...

  5. iOS 8 Xcode6 设置Launch Image 启动图片

    本人apem http://www.mamicode.com/info-detail-494411.html 如何设置App的启动图,也就是Launch Image? Step1 1.点击Image. ...

  6. centos设置服务开机启动

    Linux CentOS设置服务开机启动的方法 by 天涯 · 2013/07/26 CentOS设置服务开机启动的两种方法 1.利用 chkconfig 来配置启动级别 在CentOS或者RedHa ...

  7. android 渐变展示启动屏

    启动界面Splash Screen在应用程序是很常用的,往往在启动界面中显示产品Logo.公司Logo或者开发者信息,如果应用程序启动时间比较长,那么启动界面就是一个很好的东西,可以让用户耐心等待这段 ...

  8. iOS开发——使用技术OC篇&简单九宫格锁屏功能的实现与封装

    简单九宫格锁屏功能的实现与封装 首先来看看最后的实现界面. 在这开始看下面的内容之前希望你能先大概思考活着回顾一下如果 你会怎么做,只要知道大概的思路就可以. 由于iphone5指纹解锁的实现是的这个 ...

  9. CentOS设置服务开机启动的方法

    CentOS设置服务开机启动的两种方法 1.利用 chkconfig 来配置启动级别在CentOS或者RedHat其他系统下,如果是后面安装的服务,如httpd.mysqld.postfix等,安装后 ...

随机推荐

  1. pycharm设置头文件模板(for mac)

    我们要达到的效果是每次新建一个.py文件都会有头文件,关于头文件的作用之前已做解释

  2. pikachu靶场XSS详解

    一.反射型XSS 1.get型 源码前后区别 前 <form method="get"> <input class="xssr_in" typ ...

  3. form(form基础、标签渲染、错误显示 重置信息、form属性、局部钩子、全局钩子)

    form基础 Django中的Form使用时一般有两种功能: 1.生成html标签 2.验证输入内容 要想使用django提供的form,要在views里导入form模块 from django im ...

  4. WLAN参数释义及优化建议

    1.AP覆盖范围或天线角度 1)参数释义 AP覆盖范围或天线角度直接影响到了终端连接到WLAN的信号强度. 2)优化建议 在设备的工程安装过程中,合理选择AP的位置,合理调整AP的覆盖方向或外置天线的 ...

  5. Linux下diff的操作详解

    总述 Linux diff命令用于比较文件的差异.diff以逐行的方式,比较文本文件的异同处.特别是比较两个版本不同的文件,如果指定要比较目录,则diff会比较目录中相同文件名的文件,但不会比较其中子 ...

  6. SQL(replace)替换字段中指定的字符

    语法:update 表名 set 字段名=REPLACE(字段名,'修改前的字符','修改后的字符') 例 Product商品表中Name 名字字段中描述中将'AAA' 修改成 'BBB' SQL语句 ...

  7. CF-1328 E. Tree Queries

    E. Tree Queries 题目链接 题意 给定一个树,每次询问一组点,问是否存在一条从根到某点的路径,使得该组点到该路径的最短距离不超过1 分析 从根到达某点的路径,如果覆盖到了某个点,那么一定 ...

  8. Python实现AES的CBC模式加密和解密过程详解 和 chr() 函数 和 s[a:b:c] 和函数lambda

    1.chr()函数 chr() 用一个范围在 range(256)内的(就是0-255)整数作参数,返回一个对应的字符. 2.s[a:b:c] s=(1,2,3,4,5) 1>. s[a]下标访 ...

  9. Educational Codeforces Round 94 (Rated for Div. 2) C. Binary String Reconstruction (构造)

    题意:给你一个字符串\(s\),原字符串为\(w\),如果\(i>x\)且\(w_{i-x}=1\),那么\(s_{i}=1\),如果\(i+x\le n\)且\(w_{i+x}=1\),那么\ ...

  10. 国产smartbits版本-minismb测试高恪路由器IP限速

    Minismb测试仪表是复刻smartbits的国产版本,是一款专门用于测试智能路由器,网络交换机的性能和稳定性的软硬件相结合的工具.可以通过此工具测试任何ip网络设备的端口吞吐率,带宽,并发连接数和 ...