Console class

A representation of the current console window.

Use the Console to get information about the current window and to read and write to it.

A comprehensive set of demos of using the Console class can be found in the examples/ subdirectory.

Constructors

Console()
Console.scrolling({bool recordBlanks: true})

Properties

cursorPosition Coordinate
Returns the current cursor position as a coordinate. [...]
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
newLine String
Returns the current newline string.
read-only
rawMode bool
Returns whether the terminal is in raw mode. [...]
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
windowHeight int
Returns the height of the current console window in characters. [...]
read-only
windowWidth int
Returns the width of the current console window in characters. [...]
read-only

Methods

clearScreen() → void
Clears the entire screen
cursorDown() → void
Moves the cursor one position down.
cursorLeft() → void
Moves the cursor one position to the left.
cursorRight() → void
Moves the cursor one position to the right.
cursorUp() → void
Moves the cursor one position up.
eraseCursorToEnd() → void
Erases the current line from the cursor to the end of the line.
eraseLine() → void
Erases all the characters in the current line.
hideCursor() → void
Hides the cursor. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
readKey() Key
Reads a single key from the input, including a variety of control characters. [...]
readLine({bool cancelOnBreak: false, bool cancelOnEscape: false, dynamic callback(String text, Key lastPressed)}) String
Reads a line of input, handling basic keyboard navigation commands. [...]
resetColorAttributes() → void
Resets all color attributes and text styles to the default terminal setting.
resetCursorPosition() → void
Moves the cursor to the top left corner of the screen.
setBackgroundColor(ConsoleColor background) → void
Sets the console background color to a named ANSI color. [...]
setBackgroundExtendedColor(int colorValue) → void
Sets the background to one of 256 extended ANSI colors. [...]
setForegroundColor(ConsoleColor foreground) → void
Sets the console foreground color to a named ANSI color. [...]
setForegroundExtendedColor(int colorValue) → void
Sets the foreground to one of 256 extended ANSI colors. [...]
setTextStyle({bool bold: false, bool underscore: false, bool blink: false, bool inverted: false}) → void
Sets the text style. [...]
showCursor() → void
Shows the cursor.
toString() String
Returns a string representation of this object.
inherited
write(String text) → void
Writes the text to the console.
writeErrorLine(String text) → void
Writes an error message to the console, with newline automatically appended.
writeLine([String text, TextAlignment alignment]) → void
Writes a line to the console, optionally with alignment provided by the TextAlignment enumeration. [...]

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited