플러터로 안드로이드 앱을 만들때 런처 아이콘이 화면에 표시되고 그 다음 메인 화면으로 넘어갑니다. 이 경우 스플래시 화면을 XML 독립적으로 만들었다면 시각적으로 방해가 됩니다. 예를 들면 main.dart에서 splash_screen.dart의 SplashScreen 클래스를 호출해서 스플래시를 표시하는 체제일때, 안드로이드에서 실행시 런처 아이콘이 SplashScreen 클래스보다 우선 표시되어 시각적인 방해가 되죠.
이 경우 안드로이드에서 실행한다면 해당 플러터 프로젝트에서 생성된 android 디렉토리로 가서 리소스 파일로 생성된 style.xml 파일 두개를 수정해야 합니다.
경로는 Project 패널에서 android→app→src→main→res→values→style.xml
경로는 Project 패널에서 android→app→src→main→res→values-night→style.xml
두 파일이고 대충 아래와 같아야 합니다.
res/values/style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowSplashScreenBackground">#ffffff</item>
<item name="android:windowDisablePreview">true</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">#ffffff</item>
</style>
</resources>
res/values-night/style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowSplashScreenBackground">#ffffff</item>
<item name="android:windowDisablePreview">true</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">#ffffff</item>
</style>
</resources>
여기서 중요한 대목은 첫번째 style 지정인 LaunchTheme 엘리먼트 하위 엘리먼트로
<item name="android:windowDisablePreview">true</item>
를 추가하는 것입니다.
이렇게 해두고 플러터 프로젝트를 빌드하고 실행하면 런처 아이콘이 안뜨고 앱이 실행이 됩니다.