ListGrid<T>.fromCells constructor

ListGrid<T>.fromCells(
  1. Iterable<T> cells,
  2. {required int width}
)

Creates a new grid from the given cells and width.

The cells must have a length that is a multiple of the width.

Implementation

factory ListGrid.fromCells(
  Iterable<T> cells, {
  required int width,
}) {
  if (cells.length % width != 0) {
    throw ArgumentError.value(
      cells,
      'cells',
      'The length must be a multiple of the width.',
    );
  }
  return ListGrid._(List.of(cells), width);
}