io
io copied to clipboard
Bad state: StreamSink is bound to a stream
import 'dart:io';
main() {
stdout
..writeln('hello')
..flush() // <-- ?
..writeln('world');
}
% dart --version
Dart SDK version: 2.17.5 (stable) (Tue Jun 21 11:05:10 2022 +0200) on "macos_x64"
% dart /tmp/a.dart
hello
Unhandled exception:
Bad state: StreamSink is bound to a stream
#0 _StreamSinkImpl._controller (dart:io/io_sink.dart:216:7)
#1 _StreamSinkImpl.add (dart:io/io_sink.dart:136:5)
#2 _IOSinkImpl.write (dart:io/io_sink.dart:269:5)
#3 _IOSinkImpl.writeln (dart:io/io_sink.dart:289:5)
#4 _StdSink.writeln (dart:io/stdio.dart:319:11)
#5 main (file:///tmp/a.dart:7:7)
#6 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#7 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)