get method

E get(
  1. Pos pos
)

Returns the element at a position in the grid.

The position must be within the bounds of the grid.

Example

final grid = Grid.fromRows(
  empty: Tile.wall,
  [
    [Tile.wall, Tile.wall, Tile.wall],
    [Tile.wall, Tile.floor, Tile.wall],
  ],
);
final pos = Pos(1, 1);
print(grid.get(pos)); // Tile.floor

Implementation

E get(Pos pos) {
  if (!containsPos(pos)) {
    throw RangeError('Position $pos is out of bounds');
  }
  return getUnsafe(pos);
}