経緯
こちらを参考にFlutterにスプラッシュ画面を導入してみたのですが、Androidでスプラッシュ画面からアプリ画面に遷移する際、一時的に画面が真っ黒になる事象が起きました。
本当はフェードインアニメーションでアプリ画面に遷移するはずなのですが...
(iOSは未検証)
バージョンなど
Flutter:(Channel stable, v1.17.0, on Microsoft Windows [Version 10.0.18362.836], locale ja-JP)
Dart:2.7
flutter_native_splash:0.1.9
解決方法
android/app/src/main/AndroidManifest.xml
の<activity android:name=".MainActivity" ...>
タグの中に下記<meta-data>
タグを追加すると直りました。
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
<meta-data>
タグ追加後のXMLはこんなイメージです。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.appname">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="appname"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- splash後に画面が黒くなる件の対応 ここから -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
<!-- splash後に画面が黒くなる件の対応 ここまで -->
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
参考
https://github.com/henriquearthur/flutter_native_splash/issues/54
5/5にlance-aurorさんが書いている内容をマネてみると直りました。(感謝です...)