問題及解決后的效果
環境
- Flutter Channel stable, v1.12.13+hotfix.8
- Android Studio (version 3.6)
問題
下圖是啟動時黑屏
ori (1).gif
解決后的效果
success (1).gif
解決方法
- 第一步
打開
android/app/src/main/res/drawable/launch_background.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:src="@mipmap/splash" /> //這一段原來是被注釋掉的,放一張圖片到mipmap-xxhdpi下
</item>
</layer-list>
image.png
-
第二步
打開android/app/src/main/AndroidManifest.xml
image.png
添加綠色方框中的代碼,注意在activity標簽內,代碼可以復制下面的
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@mipmap/splash" />
通過上面兩步應該就可以了