Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix this error: Struct 'Utf8' is empty. Support for empty structs is deprecated... Use Opaque instead

Tags:

flutter

dart

I recently started getting this error when I run my app. It doesn't seem to affect everything, but it is very noisy and annoying in the logs. I didn't change anything or add anything to my app that would cause something like this, the only thing I did recently was upgrade to the latest version of Flutter (I upgrade frequently, so it was only a few days since my last update).

../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4/lib/src/structs.dart:1111:7: Info: Struct 'ENUMLOGFONTEX' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class ENUMLOGFONTEX extends Struct {
      ^
../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4/lib/src/structs.dart:2835:7: Info: Struct 'BLUETOOTH_PIN_INFO' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class BLUETOOTH_PIN_INFO extends Struct {
      ^
../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4/lib/src/structs.dart:2960:7: Info: Struct 'EXCEPINFO' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class EXCEPINFO extends Struct {}
      ^
../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4/lib/src/structs.dart:2966:7: Info: Struct 'PROPERTYKEY' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class PROPERTYKEY extends Struct {}
      ^
../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4/lib/src/structs.dart:2973:7: Info: Struct 'PROPVARIANT' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class PROPVARIANT extends Struct {}
      ^
../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4/lib/src/structs.dart:2978:7: Info: Struct 'SAFEARRAY' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class SAFEARRAY extends Struct {}
      ^
../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4/lib/src/structs.dart:2985:7: Info: Struct 'CLSID' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class CLSID extends Struct {}
      ^
../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4/lib/src/structs.dart:2992:7: Info: Struct 'STATSTG' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class STATSTG extends Struct {}
      ^
../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4/lib/src/structs.dart:2999:7: Info: Struct 'NLM_SIMULATED_PROFILE_INFO' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class NLM_SIMULATED_PROFILE_INFO extends Struct {}
      ^
../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/ffi-0.1.3/lib/src/utf8.dart:23:7: Info: Struct 'Utf8' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class Utf8 extends Struct {
      ^
../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/ffi-0.1.3/lib/src/utf16.dart:16:7: Info: Struct 'Utf16' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class Utf16 extends Struct {
      ^

The last error in the list looks slightly different:

../../../../../flutter/flutter/.pub-cache/hosted/pub.dartlang.org/ffi-0.1.3/lib/src/allocation.dart:47:33: Info: Support for using non-constant type arguments 'T' in this FFI API is deprecated and will be removed in the next stable version of Dart. Rewrite the code to ensure that type arguments are compile time constants referring to a valid native type.
  final int totalSize = count * sizeOf<T>();
                                ^

Any idea how I can fix this? I tried flutter clean but that didn't fix it.

Here's my flutter doctor output:

Flutter 1.26.0-13.0.pre.190 • channel master • https://github.com/flutter/flutter.git
Framework • revision 7db172b24d (50 minutes ago) • 2021-01-26 17:18:40 -0800
Engine • revision b11bef83a5
Tools • Dart 2.12.0 (build 2.12.0-263.0.dev)

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.26.0-13.0.pre.190, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Community Edition (version 2020.3.1)
[✓] VS Code (version 1.52.1)
[✓] Connected device (2 available)

• No issues found!
like image 822
Peter R Avatar asked Jan 27 '21 03:01

Peter R


4 Answers

Apparently this flutter SDK version has an errors, the previous version working well, you can solve this problems using this command in flutter console:

flutter downgrade
like image 74
Merlí Escarpenter Pérez Avatar answered Nov 19 '22 05:11

Merlí Escarpenter Pérez


I faced the same issue on dev channel. I solved the issue without downgrade. just add this dependency:

ffi: ^1.0.0
like image 17
Hisham Bakr Avatar answered Nov 19 '22 05:11

Hisham Bakr


This is temporary for users on the master channel. FFI will soon no allow empty Struct objects, and instead classes like Utf8 should now extend from Opaque. We're in an interim phase where the SDK has been upgraded but the package:ffi package hasn't been updated yet, hence the messages if you're running on the latest master build. The messages should be non-fatal.

like image 6
Tim Sneath Avatar answered Nov 19 '22 06:11

Tim Sneath


I have same issue , it's all with Flutter last version Just downgrade and make sure you are on the Stable channel version not beta

flutter channel stable
like image 3
Omar Essam Avatar answered Nov 19 '22 06:11

Omar Essam