size_annotation_dimensions
'Array's must have an 'Array' annotation that matches the dimensions.
Description
#The analyzer produces this diagnostic when the number of dimensions specified in an Array
annotation doesn't match the number of nested arrays specified by the type of a field.
For more information about FFI, see C interop using dart:ffi.
Example
#The following code produces this diagnostic because the field a0
has a type with three nested arrays, but only two dimensions are given in the Array
annotation:
import 'dart:ffi';
final class C extends Struct {
@Array(8, 8)
external Array<Array<Array<Uint8>>> a0;
}
Common fixes
#If the type of the field is correct, then fix the annotation to have the required number of dimensions:
import 'dart:ffi';
final class C extends Struct {
@Array(8, 8, 4)
external Array<Array<Array<Uint8>>> a0;
}
If the type of the field is wrong, then fix the type of the field:
import 'dart:ffi';
final class C extends Struct {
@Array(8, 8)
external Array<Array<Uint8>> a0;
}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.