annotation_on_pointer_field
Fields in a struct class whose type is 'Pointer' shouldn't have any annotations.
Description
#The analyzer produces this diagnostic when a field that's declared in a subclass of Struct
and has the type Pointer
also has an annotation associated with it.
For more information about FFI, see C interop using dart:ffi.
Example
#The following code produces this diagnostic because the field p
, which has the type Pointer
and is declared in a subclass of Struct
, has the annotation @Double()
:
dart
import 'dart:ffi';
final class C extends Struct {
@Double()
external Pointer<Int8> p;
}
Common fixes
#Remove the annotations from the field:
dart
import 'dart:ffi';
final class C extends Struct {
external Pointer<Int8> p;
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.