packed_annotation_alignment
Only packing to 1, 2, 4, 8, and 16 bytes is supported.
Description
#The analyzer produces this diagnostic when the argument to the Packed
annotation isn't one of the allowed values: 1, 2, 4, 8, or 16.
For more information about FFI, see C interop using dart:ffi.
Example
#The following code produces this diagnostic because the argument to the Packed
annotation (3
) isn't one of the allowed values:
dart
import 'dart:ffi';
@Packed(3)
final class C extends Struct {
external Pointer<Uint8> notEmpty;
}
Common fixes
#Change the alignment to be one of the allowed values:
dart
import 'dart:ffi';
@Packed(4)
final class C extends Struct {
external Pointer<Uint8> notEmpty;
}
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.