missing_ annotation_ on_ struct_ field
Details about the 'missing_annotation_on_struct_field' diagnostic produced by the Dart analyzer.
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.12.2 版本报告页面问题.