When running the flutter build appbundle command, I get the following error :

../../.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.

I am using Flutter 3.10.0. The project was running fine before I updated the flutter version.

11

There are 11 best solutions below

0
On BEST ANSWER

I finally fix my problem by overriding these packages in my project's pubspec.yaml

dependency_overrides:
  package_info_plus: ^4.0.1
  wakelock_windows: any
  win32: any

or

dependency_overrides:
  package_info_plus: any

Overriding the package_info_plus to ^4.0.1 gave me the following error message because of my project dependencies.

Because no versions of wakelock_windows match >0.2.1 <0.3.0 and wakelock_windows <0.2.1 depends on win32 ^2.0.0, wakelock_windows <0.2.1-∞ or >0.2.1 <0.3.0 requires win32 ^2.0.0. And because wakelock_windows 0.2.1 depends on win32 ^3.0.0, wakelock_windows <0.3.0 requires win32 ^2.0.0 or ^3.0.0. And because package_info_plus >=4.0.1 depends on win32 >=4.0.0 <6.0.0 and wakelock 0.6.2 depends on wakelock_windows ^0.2.0, package_info_plus >=4.0.1 is incompatible with wakelock 0.6.2. Because chewie >=1.3.5 depends on wakelock ^0.6.2 and no versions of wakelock match >0.6.2 <0.7.0, chewie >=1.3.5 requires wakelock 0.6.2. Thus, package_info_plus >=4.0.1 is incompatible with chewie >=1.3.5. So, because start depends on both chewie ^1.4.0 and package_info_plus ^4.0.1, version solving failed.

If you have a similar message after overriding the package_info_plus, you can check the dependent packages and add them to dependency_overrides and set the version to any as in my above example.


The Any keyword can be used to specify that any version of a package is acceptable. This can be useful if you want to make sure that your app is compatible with the latest version of a package, or if you want to avoid breaking changes that may be introduced in a future version of a package.

0
On

you can simply fix this problem by overriding the dependency, put the following code in your pubspec.yaml and that would fix your problem:

dependency_overrides:
 package_info_plus_windows: 3.0.0
0
On

I have same problem.

In my case related to flutter_app_version_checker. version 0.3.2 has dependency to old package_info_plus_x packages.

Somebody already PR the fix for flutter_app_version_checker, but package does not releases..

So I fork the repo and apply fix for my project.

  # from
dependencies:
  http: ^0.13.4
  package_info_plus: ^1.4.2

dev_dependencies:
  flutter_lints: ^1.0.0

  # to
dependencies:
  http: ^0.13.6
  package_info_plus: ^4.0.0

dev_dependencies:
  flutter_lints: ^2.0.1

pubspec.yaml

....
 flutter_app_version_checker:
    git:
      url: [email protected]:kevin-chnp/app_version_checker.git
...
(you can use your own repo)
1
On

For me was flutter screen utils and google font

i did first is type

flutter pub upgrade or flutter pub upgrade --major-versions

then i change my ext.kotlin to latest in android folder then build gradle to

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

then i able to run my project i hope this helps.

0
On

Adding this to pubspec.yaml should resolve the issue

dependency_overrides:
 package_info_plus: ^4.0.1
1
On

I had same issue and I solved mine by going into my file_version_info file and made them not nullable.

Example: From this:

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

  @Uint16()
  external int? wCodePage;
}

to this:

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

  @Uint16()
  external int wCodePage;
}

you can find this file in

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

I hope this helps.

0
On

i had this error after upgrading flutter, just run "dart pub upgrade"

0
On

I faced the same issue but after reading carefully the logs, I added this part in pub spec file

dependency_overrides:
    package_info_plus: any

I needed also to update the firebase/auth packages to 10.9. I run this command --> pod update Firebase/Auth

1
On

In order to fix this issue you will open file_version_info.dart from your path

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

and search about int? wCodePage; and int? wLanguage; then remove ?.

0
On

I've worked on this error for 2 days: my solution (but is not the best solution) is to update the 'file_version_info.dart' with:

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

  @Uint16()
  external int wCodePage;
}

and remove the int?

It works.

1
On

This worked for me:

flutter pub remove package_info_plus
flutter pub add package_info_plus

This deletes the outdated packages:

These packages are no longer being depended on:
- package_info_plus 1.4.3+1
- package_info_plus_linux 1.0.5
- package_info_plus_macos 1.3.0
- package_info_plus_platform_interface 1.0.2
- package_info_plus_web 1.0.6
- package_info_plus_windows 2.1.0
Changed 6 dependencies!

Then it adds the new packages back in - without adding the outdated ones

+ package_info_plus 4.1.0
+ package_info_plus_platform_interface 2.0.1
> win32 5.0.6 (was 3.1.4)

I think what really happened here is that the package changed and didn't need these additional platform specific files anymore, but the package manager can't quite handle this change and doesn't remove the stale packages.

The stale package package_info_plus_windows then causes the error.

When we remove the package, it removes all dependencies correctly.

When we then add the package back in, it adds the new dependencies correctly.

Problem solved.