TerminalCapabilities class
Detects terminal capabilities for ANSI color support.
This class provides automatic detection of whether the current environment supports ANSI escape codes for colored output.
Usage:
if (TerminalCapabilities.supportsAnsiColors) {
print('\x1B[32mGreen text\x1B[0m');
} else {
print('Plain text');
}
Platform behavior:
- iOS/Android: Returns
false(Xcode/Logcat don't render ANSI) - macOS/Linux terminal: Returns
true - Windows: Checks for modern terminal support
- Web: Returns
false
Constructors
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
- supportsAnsiColors → bool
-
Returns
trueif the current terminal supports ANSI escape codes.no setter
Static Methods
-
reset(
) → void - Resets the cached detection result.
-
setAnsiSupport(
bool? enabled) → void - Force enable or disable ANSI color support.