[Flutter] Splash

2024. 1. 17. 14:13dev/flutter

728x90
반응형

splash like intro. we called same mean that.

splash means a first app screen to user.

 

but, If you click my post.

because maybe you want to change splash logo or not show splash logo on your screen.

 

I will offer not show splash logo to later.

 

first splash change logo image.

you should add 'flutter_native_splash' package.

actually, logo change is best way into native platform.

 

but you don't want spand throw time.

path : https://pub.dev/packages/flutter_native_splash

 

flutter_native_splash | Flutter Package

Customize Flutter's default white native splash screen with background color and splash image. Supports dark mode, full screen, and more.

pub.dev

 

flutter pub add flutter_native_splash

 

 

you make 'flutter_native_splash.yaml' file at your project's root.

 

 

you must write to required parameter.

there are 'image, color'

 

write this on terminal

dart run flutter_native_splash:create

 

 

if you don't enough parameter.

receive this console message.

Unhandled exception:
Exception: No color string or background image!
#0      _createBackground (package:flutter_native_splash/ios.dart:437:5)
#1      _createAndroidSplash (package:flutter_native_splash/android.dart:111:3)
#2      _createSplashByConfig (package:flutter_native_splash/cli_commands.dart:154:7)
#3      createSplash (package:flutter_native_splash/cli_commands.dart:43:3)
#4      main (file:///D:/donguran/Pub/Cache/hosted/pub.dev/flutter_native_splash-2.3.9/bin/create.dart:31:5)
#5      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
#6      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

 

 

success

Building package executable... 
Built flutter_native_splash:create.
[Android] Creating default splash images
[Android] Creating default android12splash images
[Android] Creating dark mode android12splash images
[Android] Updating launch background(s) with splash image path...
[Android]  - android/app/src/main/res/drawable/launch_background.xml
[Android]  - android/app/src/main/res/drawable-v21/launch_background.xml
[Android] Updating styles...
[Android]  - android/app/src/main/res/values-v31/styles.xml
[Android] No android/app/src/main/res/values-v31/styles.xml found in your Android project
[Android] Creating android/app/src/main/res/values-v31/styles.xml and adding it to your Android project
[Android] No android/app/src/main/res/values-night-v31/styles.xml found in your Android project
[Android] Creating android/app/src/main/res/values-night-v31/styles.xml and adding it to your Android project
[Android]  - android/app/src/main/res/values/styles.xml
[Android]  - android/app/src/main/res/values-night/styles.xml
[iOS] Creating  images
[iOS] Updating ios/Runner/Info.plist for status bar hidden/visible

 

 


Splash Control

if you want close your splash at you want time.

use this code.

void main() {
  WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
  FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
  runApp(const MyApp());
}

 

and you want close time this code.

@override
void initState() {
  super.initState();
  
  // if you want timing
  FlutterNativeSplash.remove();
}
728x90
반응형

'dev > flutter' 카테고리의 다른 글

[Flutter] GestureDetector  (0) 2024.01.20
[Flutter] SnackBar  (0) 2024.01.18
[Flutter] sqflite SQLite Database #DB  (0) 2024.01.16
[Flutter] MainAxisAlignment (Row, Column)  (0) 2024.01.16
[Flutter] PIP, Picture in Picture Mode  (0) 2024.01.15