printerr function

void printerr(
  1. Object? object
)

printerr provides the equivalent functionality to the standard Dart print function but instead writes the output to stderr rather than stdout.

CLI applications should, by convention, write error messages out to stderr and expected output to stdout.

Calls toString on object and writes it to stderr.

Implementation

void printerr(Object? object) {
  final line = '$object';

  /// Co-operate with runDCliZone
  final overloaded = Zone.current[capturePrinterrKey] as CaptureZonePrintErr?;
  if (overloaded != null) {
    overloaded(line);
  } else {
    stderr.writeln(line);
  }
}