Console class
Provides static methods to manipulate the console.
Constructors
- Console()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance ↔ ConsoleExecutor
-
The static reference to the console executor.
Update this to mock the console executor.
getter/setter pair
Static Methods
-
clearCurrentToEndLine(
) → void - Erases from the current cursor position to the end of the line.
-
clearCurrentToEndScreen(
) → void - Erases from the current cursor position to the end of the screen.
-
clearCurrentToStartLine(
) → void - Erases from the current cursor position to the start of the line.
-
clearCurrentToStartScreen(
) → void - Erases from the current cursor position to the start of the screen.
-
clearDisplayNative(
int n) → void -
Native erase display sequence.
Use
eraseCurrentToEndScreen
,eraseCurrentToStartScreen
,eraseScreen
,eraseScreenClearScrollback
for convenience. -
clearLine(
{bool resetCursor = true}) → void - Erases the entire current line. By default, it also moves the cursor to the start of the line.
-
clearLineNative(
int n) → void - Native erase line sequence.
-
clearScreen(
{bool resetCursor = true}) → void - Erases the entire screen. By default, it also moves the cursor to top left.
-
clearScreenClearScrollback(
) → void - Erases the entire screen and clears the scrollback buffer.
-
draw(
ConsoleComponent component, {bool restoreCursor = false, ConsoleCoordinate? cursor}) → void - Draws a component to the console.
-
drawMultiple(
Iterable< AbsoluteConsoleComponent> components, {bool restoreCursor = true, ConsoleCoordinate? cursor}) → void - Draws multiple components to the console. Components should draw with the absolute cursor position.
-
getCursorPosition(
) → ConsoleCoordinate - Returns the current cursor position.
-
getWindowHeight(
) → int - Returns the height of the terminal. It is the number of rows in the terminal.
-
getWindowWidth(
) → int - Returns the width of the terminal. It is the number of columns in the terminal.
-
moveBackward(
[int n = 1]) → void -
Moves the cursor backward (left) by
n
columns; the default is 1. If the cursor is already at the edge of the screen, this has no effect. -
moveDown(
[int n = 1]) → void -
Moves the cursor down by
n
rows; the default is 1. If the cursor is already at the edge of the screen, this has no effect. -
moveForward(
[int n = 1]) → void -
Moves the cursor forward (right) by
n
columns; the default is 1. If the cursor is already at the edge of the screen, this has no effect. -
moveNextLine(
[int n = 1]) → void -
Moves the cursor to the beginning of the line
n
lines down (default 1). -
movePrevLine(
[int n = 1]) → void -
Moves the cursor to the beginning of the line
n
lines up (default 1). -
moveTo(
int x, int y) → void - Moves the cursor to the specific position (x, y). Indices start at 1, not 0.
-
moveToBottomLeft(
) → void - Moves the cursor to the bottom left.
-
moveToBottomRight(
) → void - Moves the cursor to the bottom right.
-
moveToColumn(
int n) → void - Moves the cursor to column n.
-
moveToTopLeft(
) → void - Moves the cursor to the top left.
-
moveToTopRight(
) → void - Moves the cursor to the top right.
-
moveUp(
[int n = 1]) → void -
Moves the cursor up by
n
rows; the default is 1. If the cursor is already at the edge of the screen, this has no effect. -
readDouble(
{String? prompt, Encoding encoding = io.systemEncoding}) → double? - Reads the next double from the console.
-
readInt(
{String? prompt, Encoding encoding = io.systemEncoding}) → int? - Reads the next integer from the console.
-
readLine(
{String? prompt, Encoding encoding = io.systemEncoding, bool retainNewlines = false}) → String - Reads a line from the console.
-
scrollDown(
int n) → void - Scroll down by n lines. New lines are added at the top.
-
scrollUp(
int n) → void - Scroll up by n lines. New lines are added at the bottom.
-
write(
String message, {SimpleColor? foregroundColor, SimpleColor? backgroundColor}) → void - Writes a string to the console without a newline.
-
writeLine(
String? message, {SimpleColor? foregroundColor}) → void - Writes a string to the console with a newline.