Rod
Rod

Reputation: 464

I can't print to VSCode's console with stdout.write

I'm running a flutter application in VSCode and want to print to console using this code:

  stdout.write('Text');

But the console doesn't show anything after executing this line. Why is that? (print statements work as expected).

EDIT: the print function works fine. I just wanted to print something inside a for loop without a newline, that's why I was trying to use stdout.writeln. I ended up building the string I wanted to print in the for loop and printing it only once with the print function.

Upvotes: 7

Views: 4029

Answers (3)

TechAurelian
TechAurelian

Reputation: 5811

I had the same problem, "solved" it using StringBuffer and one final print:

final StringBuffer buffer = StringBuffer();
for (var i = 0; i < 100; i++) {
  buffer.write('$i, ');
}
print(buffer.toString());

Upvotes: 3

Vinz
Vinz

Reputation: 240

I had the same problem myself.

Unfortunately I can't tell you the reason why stdout doesn't work on terminal logs but I can tell you that you can see them using Dart DevTools on the part of Logging

Upvotes: -1

LgFranco
LgFranco

Reputation: 1044

Just use print("Hello console"); =D

Upvotes: 0

Related Questions