cvt2D method Null safety

List cvt2D(
  1. List list,
  2. int row,
  3. int column
)

Implementation

List cvt2D(List list, int row, int column) {
  List flat = flatten(list);
  List temp;
  if (column == -1) {
    column = (flat.length / row).round();
    temp = generate(flat, [row, column]);
    return temp;
  }
  if (flat.length == row * column) {
    temp = generate(flat, [row, column]);
    return temp;
  } else {
    throw new Exception(
        'DartTensorException: Tensor of shape ${getDim(list)} cannot be convered to 2D Tensor with shape [$row,$column]');
  }
}