错误:字段“wLanguage”不能为空或类型为“Null”,它必须是“int”、“double”、“Pointer”或“Struct”或“Union”的子类型

ged*_*lod 35 flutter flutter-dependencies flutter3.x

运行flutter build appbundle命令时,我收到以下错误:

../../.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart:13:17: 
Error: Field 'wLanguage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`.
  external int? wLanguage;
                ^

../../.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart:16:17: 
Error: Field 'wCodePage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`.
  external int? wCodePage;
                ^
Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.
Run Code Online (Sandbox Code Playgroud)

我使用的是颤振3.10.0。在我更新flutter版本之前,项目运行得很好。

ged*_*lod 26

我终于通过覆盖项目中的这些包来解决我的问题pubspec.yaml

\n
dependency_overrides:\n  package_info_plus: ^4.0.1\n  wakelock_windows: any\n  win32: any\n
Run Code Online (Sandbox Code Playgroud)\n

或者

\n
dependency_overrides:\n  package_info_plus: any\n
Run Code Online (Sandbox Code Playgroud)\n
\n

由于我的项目依赖性,覆盖package_info_plus to 给了我以下错误消息。^4.0.1

\n
\n

因为没有任何版本的wakelock_windows匹配>0.2.1<0.3.0并且wakelock_windows<0.2.1依赖于win32^2.0.0,所以wakelock_windows<0.2.1-\xe2\x88\x9e或>0.2.1<0.3.0需要win32 ^2.0.0。\n并且因为wakelock_windows 0.2.1依赖于win32 ^3.0.0,wakelock_windows <0.3.0需要win32 ^2.0.0或^3.0.0。\n并且因为package_info_plus >=4.0.1依赖于win32 >=4.0.0 <6.0.0 并且wakelock 0.6.2 取决于wakelock_windows ^0.2.0,package_info_plus >=4.0.1 与wakelock 0.6.2 不兼容。\n因为chewie >=1.3.5 取决于wakelock ^0.6。 2 且没有唤醒锁版本匹配 >0.6.2 <0.7.0,chewie >=1.3.5 需要唤醒锁 0.6.2。\n因此,package_info_plus >=4.0.1 与chewie >=1.3.5 不兼容。\n因此,因为start同时依赖chewie ^1.4.0和package_info_plus ^4.0.1,版本解析失败。

\n
\n

如果您在覆盖后出现类似的消息package_info_plus,您可以检查依赖包并将它们添加到dependency_overrides并将版本设置any为如我上面的示例所示。

\n
\n

Any关键字可用于指定包的任何版本都是可接受的。如果您想确保您的应用程序与软件包的最新版本兼容,或者您​​想避免未来版本的软件包中可能引入的重大更改,这可能会很有用。

\n


小智 11

我遇到了同样的问题,我通过进入 file_version_info 文件并使它们不可为空来解决我的问题。

示例:从此:

class _LANGANDCODEPAGE extends Struct {
  @Uint16()
  external int? wLanguage;

  @Uint16()
  external int? wCodePage;
}
Run Code Online (Sandbox Code Playgroud)

对此:

class _LANGANDCODEPAGE extends Struct {
  @Uint16()
  external int wLanguage;

  @Uint16()
  external int wCodePage;
}
Run Code Online (Sandbox Code Playgroud)

你可以在以下位置找到这个文件

/Users/name/.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart

我希望这有帮助。


Arb*_*hil 5

对我来说是颤动屏幕实用程序和谷歌字体

我首先做的是输入

flutter pub upgrade或者 flutter pub upgrade --major-versions

然后我将 ext.kotlin 更改为 android 文件夹中的最新版本,然后将 gradle 构建为

ext.kotlin = '1.6.20' 到ext.kotlin_version = '1.8.21'

然后我就可以运行我的项目了,希望这会有所帮助。


小智 5

为了解决这个问题,您将从您的路径中打开 file_version_info.dart

../../.pub-cache/hosted/pub.dev/package_info_plus_windows 2.1.0/lib/src/file_version_info.dart
Run Code Online (Sandbox Code Playgroud)

并搜索int? wCodePage;然后int? wLanguage;删除?