non_positive_array_dimension
Details about the 'non_positive_array_dimension' diagnostic produced by the Dart analyzer.
Array dimensions must be positive numbers.
Description
#
The analyzer produces this diagnostic when a dimension given in an Array
annotation is less than or equal to zero (0).
For more information about FFI, see C interop using dart:ffi.
Example
#
The following code produces this diagnostic because an array dimension of
-8 was provided:
import 'dart:ffi';
final class MyStruct extends Struct {
@Array(-8)
external Array<Uint8> a0;
}
Common fixes
#Change the dimension to be a positive integer:
import 'dart:ffi';
final class MyStruct extends Struct {
@Array(8)
external Array<Uint8> a0;
}
If this is a variable length inline array, change the annotation to
Array.variable():
import 'dart:ffi';
final class MyStruct extends Struct {
@Array.variable()
external Array<Uint8> a0;
}
除非另有说明,文档之所提及适用于 Dart 3.10.3 版本报告页面问题.