美文网首页
原生Flutter在安卓端启动白屏(黑屏)问题

原生Flutter在安卓端启动白屏(黑屏)问题

作者: zxq_kyle | 来源:发表于2020-03-30 15:12 被阅读0次

问题及解决后的效果

环境

  • Flutter Channel stable, v1.12.13+hotfix.8
  • Android Studio (version 3.6)

问题

下图是启动时黑屏


ori (1).gif

解决后的效果

success (1).gif

解决方法

  1. 第一步
    打开
    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
  1. 第二步
    打开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" />

通过上面两步应该就可以了

相关文章

网友评论

      本文标题:原生Flutter在安卓端启动白屏(黑屏)问题

      本文链接:https://www.haomeiwen.com/subject/dpjvuhtx.html