1
import 'dart:io'
void main(){
stdout.write("abc");}

that code doesn't worked but

void main(){
stdout.writeln("abc");}

was work!! output is "abc" and

void main(){
stdout.write("abc");
stdout.writeln("def");}

out put is "abcdef" I can't understand this happend...

ANSAN LEE
  • 13
  • 2

1 Answers1

2

Both write and writeln are non-blocking, with the difference that writeln is causing the buffer to be flushed. Your first code would work if you await a flush before ending your program:

import 'dart:io'

void main() async {
    stdout.write("abc");
    await stdout.flush();
}
puelo
  • 5,464
  • 2
  • 34
  • 62