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.



WritableBuffer(int width, int height, {Cell initialCell})
Creates a new buffer of the specified width and height.
WritableBuffer.fromCells(Iterable<Cell> cells, {required int width})
Creates a new buffer by copying a predefined collections of cells.
WritableBuffer.fromMatrix(List<List<Cell>> cells)
Creates a new buffer by copying a nested list (2D matrix) of cells.


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


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).
inBounds(int x, int y) bool
Returns whetyher x and y are considered within bounds of the buffer.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
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/or height.
set(int x, int y, Cell value) → void
Sets the cell located at (x, y) to value.
toDebugString() String
Returns a plain-text preview of the underlying buffer.
toList() List<Cell>
Returns the buffer as a list of cells.
toMatrix() List<List<Cell>>
Returns the buffer as a nested list (2D matrix) of cells.
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.
operator [](int index) Cell
Returns the cell located at the specified index.
operator []=(int index, Cell cell) → void
Sets the cell located at the specified index to cell.