본문 바로가기
프로그래밍/Flutter <Dart>

[Flutter] flutter_native_splash 사용하여 Splash Screen 구현하기

by TaeGyeong Lee 2024. 10. 6.

설치 

플러그인을 설치합니다.

flutter pub add flutter_native_splash

 

pubspec.yaml 에 옵션 추가

아래와 같이 pubspec.yaml 파일에 옵션을 추가하세요. 모든 옵션은 여기서 확인해 주세요. 

주의 
안드로이드 12 이상 운영체제를 탑재한 기기는 이미지가 클립화 되어 이상하게 출력될 수 있습니다. 이미지 크기를 조정해 주세요.
flutter_native_splash:
  color: "#ffffff"
  image: image/logo.png
  android: true
  android_12:
    image: image/logo.png
  ios: true

 

적용 

아래 명령어를 통해 splash screen 옵션을 적용해 주세요. 옵션이 바뀔 때마다 적용이 필요합니다. 

dart run flutter_native_splash:create

 

참고 : android 12+ 이미지가 계속 짤릴 때 

1152px * 1152px 파일 정중앙에 525px * 525px 정사각형 내 이미지가 삽입된 파일을 적용해 보세요. 

 

참고 : 빌드 클린 

flutter clean
flutter pub get

 

참고 자료 

 

GitHub - jonbhanson/flutter_native_splash: Automatically generates native code for adding splash screens in Android and iOS. Cus

Automatically generates native code for adding splash screens in Android and iOS. Customize with specific platform, background color and splash image. - jonbhanson/flutter_native_splash

github.com

 

In Android 12 image is not showing · Issue #370 · jonbhanson/flutter_native_splash

I was using the native splash screen library and it's working fine on both android and ios, but when I test it on Android 12 then the image is not showing there, the only icon of the application is...

github.com