Log message to the terminal using the log method from dart:developer on an Apple Silicon Mac

155 views Asked by At

I recently switched from an Intel-based Mac to an Apple Silicon Mac. In my Flutter projects, I use the log function from dart:developer to display messages in the console during debugging. However, I've observed that these messages are only visible on the terminal when I use print or debugPrint. While I can switch to using debugPrint, I prefer the distinctive yellow-colored messages as they are easier to distinguish from other terminal outputs.

Is there a workaround to view the log messages on the terminal?

import 'dart:developer';
log('message'); // does not work
print('message') // works
debugPrint('message') // works

PS: This works perfectly on the intel-based mac

1

There are 1 answers

0
Vonarian On

You need stdout from dart:io.

Here's a minimal example:

import 'dart:io';

void main(List<String> arguments) {
  stdout.write('message');
  // On a new line
  stdout.writeln('message');
}

Read more about this class of dart:io library: https://api.dart.dev/stable/3.1.3/dart-io/Stdout-class.html

In case you want colored output, try using ansicolor