computeNumDimensions static method

int computeNumDimensions(
  1. Object? o
)

Returns the number of dimensions of a multi-dimensional array, otherwise 0.

Implementation

static int computeNumDimensions(Object? o) {
  if (o == null || o is! List) {
    return 0;
  }
  if (o.isEmpty) {
    throw ArgumentError('Array lengths cannot be 0.');
  }
  return 1 + computeNumDimensions(o.elementAt(0));
}