Grid<E>.generate constructor
Creates a new ListGrid with the given width
and height
.
Each element in the grid is initialized by calling generator
with the
position of the element. The empty
element is used as the default value.
The width
and height
must be non-negative.
Example
final grid = Grid.generate(2, 2, (pos) => pos.x + pos.y, empty: 0);
print(grid.get(Pos(0, 0))); // 0
print(grid.get(Pos(1, 0))); // 1
Implementation
factory Grid.generate(
int width,
int height,
E Function(Pos pos) generator, {
required E empty,
}) = ListGrid<E>.generate;