fillShape static method

void fillShape(
  1. Object o,
  2. int dim,
  3. List<int>? shape
)

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);
  }
}