• Stars
    star
    116
  • Rank 294,371 (Top 6 %)
  • Language
    Java
  • License
    MIT License
  • Created about 5 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A splash screen for flutter, hide when application loaded ,it works on iOS and Android.

flutter_splash_screen

Download PRs Welcome flutter_splash_screen release License MIT RN

A splash screen API for flutter which can programatically hide and show the splash screen. Works on Android and iOS.

Content

Changes

Examples

Screenshots Screenshots
flutter_splash_screen-Android flutter_splash_screen-iOS

1. Installation

Depend on it

Run this command:

flutter pub add flutter_splash_screen

2. Plugin Configuration

Android

Update the MainActivity.kt

Update the MainActivity.kt to use flutter_splash_screen via the following changes:

package org.devio.flutter.splashscreen.example

import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity

import org.devio.flutter.splashscreen.SplashScreen // add

class MainActivity : FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        // SplashScreen.show(this) 
        // or enable full screen
        SplashScreen.show(this, true)
        super.onCreate(savedInstanceState)
    }
}

Create launch_screen.xml file

Create a file called launch_screen.xml in app/src/main/res/layout (create the layout-folder if it doesn't exist). The contents of the file should be the following:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:background="@android:color/white">

    <ImageView android:layout_width="match_parent" android:layout_height="match_parent"
        android:layout_gravity="center|top" android:scaleType="centerCrop"
        android:src="@mipmap/launch_screen" />
</FrameLayout>

Customize your launch screen by creating a launch_screen.png-file and placing it in an appropriate mipmap-folder. Android automatically scales drawable, so you do not necessarily need to provide images for all phone densities. You can create splash screens in the following folders:

  • mipmap-ldpi
  • mipmap-mdpi
  • mipmap-hdpi
  • mipmap-xhdpi
  • mipmap-xxhdpi
  • mipmap-xxxhdpi

Add a color called primary_dark in app/src/main/res/values/colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="primary_dark">#000000</color>
</resources>

Optional steps:

If you want the splash screen to be transparent, follow these steps.

Open android/app/src/main/res/values/styles.xml and add <item name="android:windowIsTranslucent">true</item> to the file. It should look like this:

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <!--设置透明背景-->
        <item name="android:windowIsTranslucent">true</item>
    </style>
</resources>

To learn more see examples

If you want to customize the color of the status bar when the splash screen is displayed:

Create android/app/src/main/res/values/colors.xml and add

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="status_bar_color"><!-- Colour of your status bar here --></color>
</resources>

Create a style definition for this in android/app/src/main/res/values/styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="SplashScreenTheme" parent="SplashScreen_SplashTheme">
        <item name="colorPrimaryDark">@color/status_bar_color</item>
    </style>
</resources>

Change your show method to include your custom style:

SplashScreen.show(this,R.style.SplashScreenTheme);

iOS

Customize your splash screen via LaunchScreen.storyboard,

Learn more to see examples

Usage

Use like so:

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_splash_screen/flutter_splash_screen.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    hideScreen();
  }

  ///hide your splash screen
  Future<void> hideScreen() async {
    Future.delayed(Duration(milliseconds: 1800), () {
      FlutterSplashScreen.hide();
    });
  }

  ...

API

Method Type Optional Description
show() function false Open splash screen (Native Method )
hide() function false Close splash screen

Testing

Contribution

Issues are welcome. Please add a screenshot of you bug and a code snippet. Quickest way to solve issue is to reproduce it in one of the examples.

Pull requests are welcome. If you want to change the API or do something big it is best to create an issue and discuss it first.


MIT Licensed

More Repositories

1

TakePhoto

一款用于在Android设备上获取照片(拍照或从相册、文件中选择)、裁剪图片、压缩图片的开源工具库
Java
7,233
star
2

react-native-splash-screen

A splash screen for react-native, hide when application loaded ,it works on iOS and Android.
Java
5,481
star
3

RNStudyNotes

React Native 研究与实践
Objective-C
3,999
star
4

awesome-flutter-cn

一个很棒的Flutter学习资源,官方教程,插件,工具,文章,App,视频教程等的资源列表
2,883
star
5

GitHubPopular

这是一个用来查看GitHub最受欢迎与最热项目的App,它基于React Native支持Android和iOS双平台。#适配RN最新版在这里☞#
JavaScript
2,880
star
6

react-native-awesome

React Native 学习资源精选仓库(汇聚知识,分享精华)汇集了各类react-native学习资料、工具、组件、开源App、资源下载、以及相关新闻等,只求精不求全。
1,737
star
7

react-native-easy-toast

A react native module to show toast like android, it works on iOS and Android.
JavaScript
1,093
star
8

react-native-check-box

Checkbox component for react native, it works on iOS and Android.
JavaScript
513
star
9

GroupListView

仿支付宝账单列表效果
Java
64
star
10

react-native-event-bus

Event bus for react native, cross-interface communication solution, it works on iOS and Android.
JavaScript
46
star
11

GitHubTrending

This is a library for fetch object data from "https://github.com/trending".
JavaScript
38
star
12

flutter_color_plugin

A color parse package for flutter,it works on iOS and Android.
Dart
22
star
13

IncrementalUpdate

Android省流量更新、增量更新、补丁生成与应用
C
21
star
14

HeadSetControl

耳机线控实例,蓝牙耳机按钮监听
Java
21
star
15

hijson

HiJson is a lightweight JSON parsing library that can be used for HarmonyOS, Android, and Java
Java
16
star
16

Ios-HomeUI

基于AutoLayout的Ios首页导航框架,支持滑动切换,TabBar切换,侧拉栏菜单等
Objective-C
14
star
17

BreakPointUploadUtil

Java断点上传工具
Java
13
star
18

crazycodeboy.github.io

https://crazycodeboy.github.io/
HTML
11
star
19

WaitScreen

Android页面加载遮罩
Java
9
star
20

ListViewPlus

带有上拉加载下拉刷新的ListView
Java
9
star
21

openai_flutter

A openai library for flutter,it works on iOS,Android,Web,macOS and Windows.
Dart
7
star
22

underline_indicator

A underline indicator
Dart
7
star
23

awesome-harmonyos

一个很棒的HarmonyOS学习资源,官方教程,插件,工具,文章,App,视频教程等的资源列表
6
star
24

PUtils

Android,Http,orm...
Java
4
star
25

KeyboardObserver

Ios键盘输入框自适应
Objective-C
4
star
26

flutter_overlay

A transparent floating layer for flutter which can programmatically show and close the child. Works on iOS,Android and Web.
Dart
3
star
27

react-native-safe-area-plus

A flexible way to handle safe area, also works on Android and iOS
JavaScript
2
star
28

flutter_hi_cache

A cache manager based on shared_preferences. Works on iOS,Android and Web.
Dart
2
star
29

gitbook-plugin-single-page

JavaScript
1
star
30

react-native-take-photo

React Native版TakePhoto@https://github.com/crazycodeboy/TakePhoto
1
star
31

react-native-navbar-plus

A react native module to show navbar,it works on iOS and Android.
JavaScript
1
star
32

flutter_nested

Lists that support nested scrolling can customize the header and the number of lines displayed per line.
Dart
1
star
33

DigitalTimer

自定义数字时钟
Java
1
star
34

react-native-isiphonex-device

A react native module to replace DeviceInfo.isIPhoneX_deprecated.
TypeScript
1
star