ListGrid<T>.generate constructor
Creates a new grid with the given width
and height
.
The grid is filled with the result of calling generator
for each cell.
The width
and height
must be non-negative.
Implementation
factory ListGrid.generate(
int width,
int height,
T Function(int x, int y) generator,
) {
RangeError.checkNotNegative(width, 'width');
RangeError.checkNotNegative(height, 'height');
return ListGrid.fromCells(
Iterable.generate(height, (y) {
return Iterable.generate(width, (x) => generator(x, y));
}).expand((row) => row),
width: width,
);
}