fillShape static method
Recursively populates the shape dimensions for a given (multi-dimensional) array)
Implementation
static void fillShape(Object o, int dim, List<int>? shape) {
if (shape == null || dim == shape.length) {
return;
}
final len = (o as List).length;
if (shape[dim] == 0) {
shape[dim] = len;
} else if (shape[dim] != len) {
throw ArgumentError(
'Mismatched lengths ${shape[dim]} and $len in dimension $dim');
}
for (var i = 0; i < len; ++i) {
fillShape(o.elementAt(0), dim + 1, shape);
}
}