List<int> get shape { if (isEmpty) { return <int>[]; } dynamic list = this; final List<int> shape = <int>[]; while (list is List) { shape.add(list.length); list = list.elementAt(0); } return shape; }