flutter_native_splash启动图图片不显示问题排查与解决
Flutter flutter_native_splash 启动图不显示问题解决
问题表现
使用flutter_native_splash插件配置启动页时,背景色能正常生效,但启动图片始终无法显示。
已尝试的排查操作
- 确认assets目录在项目根目录,且pubspec.yaml中资源路径配置正确
- 严格按照插件官方步骤完成pubspec.yaml配置
- 测试过500x500、120x120等多种尺寸的PNG格式图片
- 执行过
flutter clean、flutter pub get、flutter pub run flutter_native_splash:remove、flutter pub run flutter_native_splash:create等命令 - 检查
android/app/src/main/res目录,发现各分辨率的启动图片已生成,但运行应用时仍不显示
最终解决办法
在flutter_native_splash的配置中新增android_12节点,单独为Android 12及以上版本配置启动图和背景色。示例配置如下:
flutter_native_splash: # 通用配置 color: "#ffffff" image: assets/splash.png # Android 12+专属配置 android_12: image: assets/splash_android12.png color: "#ffffff"
配置完成后,重新执行flutter pub run flutter_native_splash:create生成启动资源,再次运行应用即可正常显示启动图片。
内容的提问来源于stack exchange,提问作者Dawit M
相关产品推荐
相关产品推荐

