printLog function

void printLog(
  1. String message,
  2. bool debug, {
  3. LogColor color = LogColor.reset,
})

Used to print logs in console

Implementation

void printLog(String message, bool debug, {LogColor color = LogColor.reset}) {
  if (!debug) return;

  const Map<LogColor, String> colors = {
    LogColor.reset: '\x1B[0m',
    LogColor.black: '\x1B[30m',
    LogColor.red: '\x1B[31m',
    LogColor.green: '\x1B[32m',
    LogColor.yellow: '\x1B[33m',
    LogColor.blue: '\x1B[34m',
    LogColor.magenta: '\x1B[35m',
    LogColor.cyan: '\x1B[36m',
    LogColor.white: '\x1B[37m',
    LogColor.orange: '\x1B[38;5;208m',
  };

  stdout.write('${colors[color]}$message\n${colors[LogColor.reset]}');
}