Grid<E>.filled constructor

Grid<E>.filled(
  1. int width,
  2. int height, {
  3. required E empty,
  4. E? fill,
})

Creates a new ListGrid with the given width and height.

Each element in the grid is initialized to empty, which is also used as the default, or Grid.empty, element. An empty element still consumes memory, but is used to allow resizing the grid.

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.filled(
  int width,
  int height, {
  required E empty,
  E? fill,
}) = ListGrid<E>.filled;