https://github.com/crazycodeboy/flutter_splash_screen
A splash screen for flutter, hide when application loaded ,it works on iOS and Android.
https://github.com/crazycodeboy/flutter_splash_screen
android flutter flutter-splash-screen ios splash-screen splashscreen
Last synced: about 1 month ago
JSON representation
A splash screen for flutter, hide when application loaded ,it works on iOS and Android.
- Host: GitHub
- URL: https://github.com/crazycodeboy/flutter_splash_screen
- Owner: crazycodeboy
- License: mit
- Created: 2019-03-28T16:56:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-19T04:46:36.000Z (over 1 year ago)
- Last Synced: 2024-12-18T07:01:56.294Z (6 months ago)
- Topics: android, flutter, flutter-splash-screen, ios, splash-screen, splashscreen
- Language: Kotlin
- Size: 2.35 MB
- Stars: 131
- Watchers: 7
- Forks: 28
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# flutter_splash_screen
[ ](https://pub.dartlang.org/packages/flutter_splash_screen)
[ ](https://github.com/crazycodeboy/flutter_splash_screen/pulls)
[ ](https://github.com/crazycodeboy/GitHubPopular/releases)
[](https://raw.githubusercontent.com/crazycodeboy/flutter-check-box/master/LICENSE)
[ ](https://github.com/crazycodeboy/react-native-splash-screen)A splash screen API for flutter which can programatically hide and show the splash screen. Works on
Android and iOS.## Content
- [Changes](#changes)
- [Installation](#installation)
- [Examples](#examples)
- [Getting started](#getting-started)
- [API](#api)
- [Testing](#testing)
- [Troubleshooting](#troubleshooting)
- [Contribution](#contribution)## Changes
## Examples
* [Examples](https://github.com/crazycodeboy/flutter_splash_screen/tree/master/example)
Screenshots | Screenshots
------|--------
 | ## 1. Installation
### Depend on it
Run this command:
```bash
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:
```kotlin
package org.devio.flutter.splashscreen.exampleimport android.os.Bundle
import io.flutter.embedding.android.FlutterActivityimport 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
```
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`
```
#000000
```
**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 `true` to the file. It should look like this:```xml
<!-- Customize your theme here. -->
<!--设置透明背景-->
<item name="android:windowIsTranslucent">true</item>
```
**To learn more
see [examples](https://github.com/crazycodeboy/flutter_splash_screen/tree/master/example)**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
```
Create a style definition for this in `android/app/src/main/res/values/styles.xml`:
```xml
<item name="colorPrimaryDark">@color/status_bar_color</item>
```
Change your `show` method to include your custom style:
```java
SplashScreen.show(this,R.style.SplashScreenTheme);
```### iOS
Customize your splash screen via `LaunchScreen.storyboard`,
**Learn more to
see [examples](https://github.com/crazycodeboy/flutter_splash_screen/tree/master/example)**## Usage
Use like so:
```dart
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 {
@override
void initState() {
super.initState();
hideScreen();
}///hide your splash screen
Future 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](https://github.com/crazycodeboy/flutter_splash_screen/blob/master/LICENSE)**