print() without a newline in Dart?
DartDart Problem Overview
In Dart, I am using print()
to write content to the console.
Is it possible to use print()
without it automatically adding a newline to the output?
Dart Solutions
Solution 1 - Dart
You can use stdout
:
import "dart:io";
stdout.write("foo");
will print foo
to the console but not place a \n
after it.
You can also use stderr
. See:
https://stackoverflow.com/questions/12181658/how-can-i-print-to-stderr-in-dart-in-a-synchronous-way
Solution 2 - Dart
You cannot customize the print() to prevent printing a newline in Dart (as in Python by using 'end' argument). To achieve this in Dart, use stdout.write() function, like
stdout.write("<your_message>");
Solution 3 - Dart
Have a look are the dcli package you can use the echo function.