ListGrid<E>.filled constructor
Creates a new list grid 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 positive.
Example
final grid = ListGrid.filled(2, 2, empty: 0);
print(grid.width); // 2
print(grid.height); // 2
print(grid.get(Pos(0, 0))); // 0
Implementation
factory ListGrid.filled(
int width,
int height, {
required E empty,
E? fill,
}) {
checkPositive(width, 'width');
checkPositive(height, 'height');
final list = List.filled(
width * height,
fill ?? empty,
growable: true,
);
return _ListGrid(width, height, empty, list);
}