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

flutter_native_splash执行create命令抛出exit code 255错误求助

flutter_native_splash执行create命令抛出exit code 255错误求助

我懂你折腾好久却卡在这里的难受,咱们直接看问题根源:

错误提示已经把原因说得明明白白了:Exception: Your pubspec.yaml file does not contain a flutter_native_splash section——你的pubspec.yaml里缺少flutter_native_splash的专属配置段,这可不是只在dependencies里加个包就能搞定的。

你提到已经在依赖里添加了这个包,但这个包需要额外的配置来定义启动页的颜色、图标等参数,具体修复步骤如下:

  1. 确认依赖配置无误
    先检查pubspec.yaml的dependencies区块,确保包已经正确引入(版本号可以根据你实际安装的调整):
dependencies:
  flutter:
    sdk: flutter
  flutter_native_splash: ^2.2.16
  1. 添加专属配置段
    在pubspec.yaml文件中,找到和dependencies、flutter同级的位置(绝对不要嵌套在dependencies里面),添加flutter_native_splash的配置内容,比如你需要的深浅主题颜色:
flutter_native_splash:
  # 浅色主题下的启动页背景色
  color: "#ffffff"
  # 深色主题下的启动页背景色
  color_dark: "#000000"
  # 可选:如果需要添加启动图标,取消注释并替换为你的图标路径
  # image: assets/images/splash_logo.png
  # 可选:设置全屏启动页(隐藏状态栏)
  # fullscreen: true
  1. 重新执行命令
    保存pubspec.yaml后,先执行flutter pub get确保依赖和配置都被正确加载,然后再运行:
flutter pub run flutter_native_splash:create

之前的exit code 255错误就是因为包找不到它需要的配置段,按上面的步骤配置后应该就能正常生成启动页了。

备注:内容来源于stack exchange,提问作者Woke Vibes Hollys

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.23 12:49:31