更多代码参考

有短暂的白屏时间

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. JAVA中两个int类型的变量在不借助第三个变量的情况下完成值的互换

    在面试中被问到这个问题,想到两种解决方式,在此分享一下. 第一种,使用简单的数学运算达到目标(但是面试官往往会问你还有没有其他方式): public static void main(String[] ...

  2. Hash Map集合和Hash Set集合

    HashMap集合的使用 1.1.每个集合对象的创建(new) 1.2.从集合中添加元素 1.3.从集合中取出某个元素 1.4.遍历集合 public class HashMapTest { publ ...

  3. 用tqdm和rich为固定路径和目标的python算法代码实现进度条

    适用场景 在存在固定长度的算法中可以可视化算法执行的过程,比如对一个固定长度的数组的遍历,就是一种适合使用进度条来进行可视化的场景.而一些条件循环,比如while循环,不一定适合使用进度条来对算法执行 ...

  4. 「一本通 1.3 例 4」Addition Chains

    Addition Chains 题面 对于一个数列 \(a_1,a_2 \dots a_{m-1},a_m\) 且 \(a_1<a_2 \dots a_{m-1}<a_m\). 数列中的一 ...

  5. 通过 JFR 与日志深入探索 JVM - TLAB 原理详解

    全系列目录:通过 JFR 与日志深入探索 JVM - 总览篇 什么是 TLAB? TLAB(Thread Local Allocation Buffer)线程本地分配缓存区,这是一个线程专用的内存分配 ...

  6. cassandra权威指南读书笔记--监控&维护

    cassandra SLF4J API记录日志,具体采用Logback实现.在终端启动cassandra时,可以向程序输入-f,就能在终端看到这个输出.Java Mangement Extension ...

  7. centos 7 部署nginx及libfastcommon

    1.编译环境 (centos)yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib- ...

  8. linux(7)top命令详细解释

    top命令 Linux top命令用于实时显示 process 的动态. top参数详解 第一行,任务队列信息 系统当前时间:13:52:56 系统开机后到现在的总运行时间:up 66 days,8m ...

  9. sh 脚本名字和./脚本名字有什么区别

    sh xxx用 sh 这个shell (sh一般指系统默认shell,比如 bash, ksh, Csh 等都有可能) 来解释和运行 xxx 这个脚本.xxx 文件不必具有可执行属性(chmod +x ...

  10. OLAP、OLTP的介绍和比较(转载)

    OLTP与OLAP的介绍 数据处理大致可以分成两大类:联机事务处理OLTP(on-line transaction processing).联机分析处理OLAP(On-Line Analytical ...