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;
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。