missing_annotation_on_struct_field
Fields of type '{0}' in a subclass of '{1}' must have an annotation indicating the native type.
Description
#The analyzer produces this diagnostic when a field in a subclass of
Struct
or Union
whose type requires an annotation doesn't have one.
The Dart types int
, double
, and Array
are used to represent multiple
C types, and the annotation specifies which of the compatible C types the
field represents.
For more information about FFI, see C interop using dart:ffi.
Example
#The following code produces this diagnostic because the field x
doesn't
have an annotation indicating the underlying width of the integer value:
import 'dart:ffi';
final class C extends Struct {
external int x;
}
Common fixes
#Add an appropriate annotation to the field:
import 'dart:ffi';
final class C extends Struct {
@Int64()
external int x;
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。