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

Flutter 3.10.0执行flutter build appbundle时遇字段非空约束错误

解决Flutter 3.10.0执行flutter build appbundle的字段Nullable错误

问题原因

Flutter 3.10.0对dart:ffi的Struct字段规则做了更新,禁止使用可空类型(int?)作为external字段的类型,而你使用的package_info_plus_windows-2.1.0版本正好包含不符合规则的可空字段,导致编译失败。

解决方案

方案1:升级package_info_plus依赖(推荐)

  • 打开项目根目录的pubspec.yaml文件,找到dependencies下的package_info_plus,将版本号更新为兼容Flutter 3.10.0的最新稳定版,例如:
    dependencies:
      package_info_plus: ^4.2.0
    
  • 执行命令更新依赖:
    flutter pub upgrade
    
  • 重新执行构建命令:
    flutter build appbundle
    

方案2:临时修改本地缓存文件(不推荐,仅临时应急)

  • 找到本地缓存文件路径:../../.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart
  • 编辑该文件,将第13行和第16行的可空字段改为非空:
    // 原第13行:external int? wLanguage;
    external int wLanguage;
    // 原第16行:external int? wCodePage;
    external int wCodePage;
    
  • 保存文件后重新执行flutter build appbundle

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 15:32:14