Stores elements of a certain type T
in a 2-dimensional grid structure.
This class is designed to implemented or used as a mixin by other implementations that provide the actual storage and retrieval of elements. If extended or mixed-in, default implementations are provided for most methods, but the implementor may choose to override them for performance.
Constructors
- Grid(int width, int height, T fill)
-
Creates a new grid with the given
width
andheight
.factory - Grid.empty()
-
Creates an empty grid with no cells.
factory
-
Grid.fromCells(Iterable<
T> cells, {required int width}) -
Creates a new grid from the given
cells
andwidth
.factory -
Grid.fromRows(Iterable<
Iterable< rows)T> > -
Creates a new grid from the given
rows
.factory - Grid.generate(int width, int height, T generator(int x, int y))
-
Creates a new grid with the given
width
andheight
.factory -
Grid.view(Grid<
T> grid, Rect bounds) -
Creates a sub-grid view into this grid within the given
bounds
.factory
Properties
-
cells
→ Iterable<
T> -
Cells in the grid.
no setter
-
columns
→ Iterable<
Iterable< T> > -
Each column of cells in the grid from left to right.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → int
-
Height of the buffer.
no setter
-
indexed
→ Iterable<
(int, int, T)> -
Each cell in the grid with its x and y coordinates.
no setter
-
rows
→ Iterable<
Iterable< T> > -
Each row of cells in the grid from top to bottom.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- width → int
-
Width of the buffer.
no setter
Methods
-
area(
[Offset offset = Offset.zero]) → Rect -
Returns the area of the grid as a rectangle with an optional
offset
. -
get(
int x, int y) → T -
Returns the cell at the given
x
andy
coordinates. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
set(
int x, int y, T cell) → void -
Sets the cell at the given
x
andy
coordinates tocell
. -
subGrid(
Rect bounds) → Grid< T> -
Returns a sub-grid view into this grid within the given
bounds
. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited