setForegroundColor method

void setForegroundColor(
  1. ConsoleColor foreground
)

Sets the console foreground color to a named ANSI color.

There are 16 named ANSI colors, as defined in the ConsoleColor enumeration. Depending on the console theme and background color, some colors may not offer a legible contrast against the background.

Implementation

void setForegroundColor(ConsoleColor foreground) {
  stdout.write(foreground.ansiSetForegroundColorSequence);
}