:/src/flutter/.pub-cache/hosted/pub.dartlang.org/ffi-0.1.3/lib/src/utf16.dart:16:7: Error: Struct ‘Utf16’ is empty. Empty structs are undefined behavior. class Utf16 extends Struct { ^ /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/ffi-0.1.3/lib/src/allocation.dart:47:33: Error: Expected type ‘T’ to be a valid and instantiated subtype of ‘NativeType’. final int totalSize = count * sizeOf(); ^
目前遇到这个问题是因为一些版本问题,解法方式添加下面的依赖包
ffi: ^1.0.0 //安装依赖

在使用Flutter的 Foreign Function Interface (FFI) 库时,遇到了因空结构体导致的错误。错误提示指向了 `Utf16` 类在 `utf16.dart` 文件以及 `allocation.dart` 文件中的定义。问题的根本原因是版本不兼容。为修复此问题,只需更新 `ffi` 依赖到最新版本,例如 `ffi: ^1.0.0`。完成依赖更新后,重新构建项目,错误应得到解决,确保项目的正常运行。

被折叠的 条评论
为什么被折叠?



