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

Overview

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

flutter_splash_screen-Android flutter_splash_screen-iOS

Installation

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_splash_screen: ^xxx

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Plugin Configuration

Android

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

package org.devio.flutter.splashscreen.example;
import android.os.Bundle;

+ import org.devio.flutter.splashscreen.flutter_splash_screen.SplashScreen;

import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
 +       SplashScreen.show(this, true);// here
        super.onCreate(savedInstanceState);
        GeneratedPluginRegistrant.registerWith(this);
    }
}

iOS

No need for this step.

Getting started

Import it

Now in your Dart code, you can use:

import 'package:flutter_splash_screen/flutter_splash_screen.dart';

Android:

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"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/launch_screen" android:scaleType="centerCrop" />
</RelativeLayout>

Customize your launch screen by creating a launch_screen.png-file and placing it in an appropriate drawable-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:

  • drawable-ldpi
  • drawable-mdpi
  • drawable-hdpi
  • drawable-xhdpi
  • drawable-xxhdpi
  • drawable-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: 3600), () {
      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

Comments
  • iOS层的还没有实现啊

    iOS层的还没有实现啊

    Run react-native info in your project and share the content.

    What react-native-splash-screen version are you using?

    What platform does your issue occur on? (Android/iOS/Both)

    Describe your issue as precisely as possible :

    1. Steps to reproduce the issue or to explain in which case you get the issue
    2. Interesting logs

    Join a screenshot or video of the problem on the simulator or device?

    Show us the code you are using?

    opened by LINGLemon 1
  • android 启动页没法全屏,上面会有状态栏占用部分空间

    android 启动页没法全屏,上面会有状态栏占用部分空间

    Run react-native info in your project and share the content.

    What react-native-splash-screen version are you using?

    What platform does your issue occur on? (Android/iOS/Both)

    Describe your issue as precisely as possible :

    1. Steps to reproduce the issue or to explain in which case you get the issue
    2. Interesting logs

    Join a screenshot or video of the problem on the simulator or device?

    Show us the code you are using?

    opened by desire0420 1
  • I made a sample of this project with embedding v2

    I made a sample of this project with embedding v2

    I made a sample of this project with new embedding v2. but not using package. check it out, if you want!!

    https://github.com/Yumin2019/flutter_splash_sample

    I'm really thankful that I can easily applied my own splash screen using this project. Thanks!!

    opened by Yumin2019 0
  • The plugin `flutter_splash_screen` uses a deprecated version of the Android embedding.

    The plugin `flutter_splash_screen` uses a deprecated version of the Android embedding.

    Hi,

    After upgrading Flutter SDK to 2.5.3 version am getting deprecated version like below warning message,

    The pluginflutter_splash_screenuses a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs. If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

    Any solution for this ?

    thanks in advance

    opened by Jai05-techie 1
  • Mainactivity.java file missing

    Mainactivity.java file missing

    In the readme file author said we have to edit Mainactivity.java file but in flutter flutter 1.12.13+hotfix8 there is no such file. When I add it I get the following error

    FAILURE: Build failed with an exception.

    What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

    Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    Get more help at https://help.gradle.org

    BUILD FAILED in 8s Gradle task assembleDebug failed with exit code 1

    opened by feliciaeponou 2
Releases(1.0.0+6)
Owner
Devio.org
专注于移动开发,分享知识,传播快乐
Devio.org
A Flutter implementation of splash screen. Supports Android and IOS.

your_splash A Flutter implementation of splash screen. Supports Android and IOS. Features Supports splash screen with the Future callback Supports spl

Stepanenko Stanislav 6 Sep 27, 2022
Android test task master - Create PIN code screen, authentication by PIN code screen and menu screen

Here is described test tasks for a android dev. Need to implement three screens:

null 3 Oct 4, 2022
Flutter package to hide out whole application or sections if you are not paid for the job done.

not_paid Worried about your payment? Using this package you can provide a non paid version of your app to the client that consistently starts fading o

hd-motion 11 Nov 30, 2021
Flutter plugin to implement a Boom Menu, with icons, title, subtitle, animated FAB Icons and hide on scrolling.

Flutter Boom Menu Usage The BoomMenu widget is built to be placed in the Scaffold.floatingActionButton argument, replacing the FloatingActionButton wi

Mohanraj 88 Aug 1, 2022
It's a universal app template to have a great animated splash screen and liquid slider. Just change the animation if you want (rive) and change the images or colours according to your app.

liquid A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this i

Zikyan Rasheed 28 Oct 7, 2022
A color parse package for flutter,it works on iOS and Android.

A color parse package for flutter,it works on iOS and Android. Getting Started To get a color Color color1 = ColorUtil.color('#f2f2f2'); Color color2

Devio.org 20 Oct 30, 2021
Flutter Login UI with splash screen and multiple color support

Flutter Login UI It's a #SpeedCode tutorial for Flutter #Login #UI project with

manushikhadka 8 Dec 22, 2022
A beautiful and animated Splash Screen UI with Flutter

Flutter Splash Screen Animation, Application Design A part of #flutter100daysofc

Behruz Hurramov 0 Dec 24, 2021
Flutter Splash Screen design and Animation - day 8

Flutter Splash Screen Animation, Application Design A part of #flutter100daysofcode. Let's create a beautiful and animated Splash Screen UI with Flutt

Mohammad Rahmani 266 Dec 29, 2022
Responsive Full Stack Reddit Clone - Works on Android, iOS & Web! built with Flutter 🚀💙

?? ??️ ?? ??️ ?? ??️ ?? ??️ UNDER CONSTRUCTION ?? ??️ ?? ??️ ?? ??️ ?? ??️ Reddit Clone ?? ?? Responsive Full Stack Reddit Clone - Works on Android, i

SOLOMON ABUH 3 Dec 15, 2022
A completely Responsive Image Editor App- Works on Android & iOS

Image Editor App Developed using Flutter with No Plugins (except for picking and saving images)

Rivaan Ranawat 20 Dec 16, 2022
Authentication + Splash Screen Flutter UI, UI created getting inspired from one share on dribble with flutter

Rest App, with Firebase Auth + SplashScreen UI created getting inspired from one share on dribble with flutter, after getting amazing responce, Added

Sanskar Tiwari 202 Dec 17, 2022
A Flutter Splash Screen For Food Delivery App

newfoodexpress A new Flutter project on board screen or splash screen for any app. But this developed for Food delivery app. Getting Started This proj

Faysal Neowaz 4 Dec 27, 2022
🎮 Style your flutter game with a beautiful splash screen.

Flame Splash Screen Style your flame game with a beautiful splash screen. This package includes a FlameSplashScreen widget. Install Add flame_splash_s

Flame Engine 38 Sep 13, 2022
Flutterkotlinlottie - A sample flutter app illustrating the implementation of a lottie splash screen natively through kotlin

flutter_lottie_splash_app A Flutter application to demonstrate how to add an ani

null 0 Jan 1, 2022
The easiest way to create your animated splash screen in a fully customizable way.

Animated Splash Screen Check it out at Pub.Dev Do it your way Assets image Custom Widget Url image IconData Or just change PageTransition and/or Splas

Clean Code 104 Nov 10, 2022
A Flutter plugin for changing the Home Screen, Lock Screen (or both) Wallpaper on Android devices.

wallpaper_manager A Flutter plugin for changing the Home Screen, Lock Screen (or both) Wallpaper(s) on Android devices. Usage Installation In the pubs

Aditya Mulgundkar 38 Nov 28, 2022
A completely Responsive Community App- Works on Android!

Seta A completely Responsive Community App- Works on Android! Features Responsive Realtime UI Email & Password Authentication Share Posts with Caption

Ashwin Sivasankaran 4 Nov 13, 2022
A splash view is a short introduction to an application shown when it is launched.

A splash view is a short introduction to an application shown when it is launched. In the splash view, basic introductory information, such as the company logo, content, etc. is displayed at the moment the application load.

Rahul Chouhan 3 Sep 3, 2022