WritableBuffer class abstract
Stores a writable 2D buffer of cells.
A writble buffer maintains a two-dimensional buffer of Cell instances, and provides methods of manipulating them programatically, such as fill and print, as well as direct "pixel" access using get and set.
Virtual buffers are also suitable for testing, as well as maintaining a platform independent stateful view that will later be synchronized to a platform-specific view.
It is considered invalid to extend, implement, or mix-in this class.
Constructors
- WritableBuffer(int width, int height, {Cell initialCell})
-
Creates a new buffer of the specified
width
andheight
.factory -
WritableBuffer.fromCells(Iterable<
Cell> cells, {required int width}) -
Creates a new buffer by copying a predefined collections of
cells
.factory -
WritableBuffer.fromMatrix(List<
List< cells)Cell> > -
Creates a new buffer by copying a nested list (2D matrix) of
cells
.factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → int
-
Height of the buffer.
no setterinherited
- length → int
-
Total number of cells in the buffer.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- width → int
-
Width of the buffer.
no setterinherited
Methods
-
clear(
[Cell cell = Cell.blank]) → void -
Fills the entire screen buffer with the attributes of the given
cell
. -
fill(
{required int x, required int y, required int width, required int height, int? character, Color? foreground, Color? background}) → void - Fills a rectangular region of the screen with the given attributes.
-
fillFrom(
Buffer other, {required int x, required int y, int sourceX = 0, int sourceY = 0, int? width, int? height}) → void -
Copies cells from
other
into the provided rectangular region. -
get(
int x, int y) → Cell -
Returns the cell located at (
x
,y
).inherited -
inBounds(
int x, int y) → bool -
Returns whetyher
x
andy
are considered within bounds of the buffer.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
print(
String text, int x, int y, {Color? foreground, Color? background}) → void -
Sets character representing
text
to a particular location. -
resize(
{int? width, int? height, Cell expand = Cell.blank}) → void -
Resizes the buffer to given
width
and/orheight
. -
set(
int x, int y, Cell value) → void -
Sets the cell located at (
x
,y
) tovalue
. -
toDebugString(
) → String -
Returns a plain-text preview of the underlying buffer.
inherited
-
toList(
) → List< Cell> -
Returns the buffer as a list of cells.
inherited
-
toMatrix(
) → List< List< Cell> > -
Returns the buffer as a nested list (2D matrix) of cells.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
int index) → Cell -
Returns the cell located at the specified
index
.inherited -
operator []=(
int index, Cell cell) → void -
Sets the cell located at the specified
index
tocell
.