Grid<T>.view constructor

Grid<T>.view(
  1. Grid<T> grid,
  2. Rect bounds
)

Creates a sub-grid view into this grid within the given bounds.

The bounds must be within the grid's area.

Implementation

factory Grid.view(Grid<T> grid, Rect bounds) {
  final area = grid.area();
  if (!area.containsRect(bounds)) {
    throw ArgumentError.value(
      bounds,
      'bounds',
      "Must be within the grid's area: $area",
    );
  }
  return _SubGrid(grid, bounds);
}