首先设置安卓启动页
在android/app/src/main/AndroidManifest.xml中添加这一行
<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" />
<!-- You can insert your own image assets here --> <item> <!-- android:gravity="center" --> <bitmap android:src="@drawable/splash"/> </item>
如果在这里不行就将代码放在同级的另一个drawable-v21文件夹中,然后将图片放在drawable文件夹中
结果运行之后发现报错图片太大,在网上压缩图片从2.9MB到400K都还是报错,最后在stackflow上找到解决办法
https://stackoverflow.com/questions/39111248/canvas-trying-to-draw-too-large-bitmap-when-android-n-display-size-set-larger/44072270#44072270?newreg=b5b40430a64f4ad9b56afac076c58228
Move your image in the drawable to mipmap-xxhdpi.Your image is in bitmap format so you should put your image in mipmap folder,then it will work
将图片从drawable中移动到mipmap-xxxhdpi中
然后更改drawable或者drawable-21文件夹中launch_background.xml的代码为新的地址
<item> <bitmap android:src="@mipmap/splash" /> </item>