You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Flutter Native Splash时自定义启动页图标不显示问题求助

Flutter Native Splash 启动页图标不显示问题

代码及运行结果截图:
代码及运行结果截图

使用Flutter Native Splash自定义启动页时,仅背景颜色生效,图标未在启动页中央显示,预期效果为蓝色背景下图标居中显示。


解决方案:

  • 检查pubspec.yaml配置,确保图标路径、参数设置准确:
    flutter_native_splash:
      color: "#007AFF" # 蓝色背景
      image: assets/images/launch_icon.png # 确认图标路径真实存在
      android: true
      ios: true
      image_scale: 0.6 # 按需调整图标缩放比例,避免显示异常
    
  • 确认图标文件格式为PNG,且路径下文件无损坏
  • 重新生成启动页资源:
    flutter pub run flutter_native_splash:create
    
  • 清理缓存后重建项目:
    flutter clean
    flutter pub get
    flutter run
    
  • Android平台可手动调整android/app/src/main/res/drawable/launch_background.xml,确保图标居中:
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@drawable/launch_icon" />
    
  • iOS平台可检查ios/Runner/Assets.xcassets/LaunchImage.imageset资源,或在LaunchScreen.storyboard中手动设置图片视图为居中布局

内容的提问来源于stack exchange,提问作者R21

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 11:34:56