field_must_be_external_in_struct
Fields of 'Struct' and 'Union' subclasses must be marked external.
Description
#The analyzer produces this diagnostic when a field in a subclass of either
Struct
or Union
isn't marked as being external
.
For more information about FFI, see C interop using dart:ffi.
Example
#The following code produces this diagnostic because the field a
isn't
marked as being external
:
dart
import 'dart:ffi';
final class C extends Struct {
@Int16()
int a;
}
Common fixes
#Add the required external
modifier:
dart
import 'dart:ffi';
final class C extends Struct {
@Int16()
external int a;
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。