how to read stdin and write to stdout with dart2js


according to this answer

the dart:io libraries are only for the server/command-line, so they
can’t be compiled with dart2js.

is it possible to read from stdin and write to stdout with dart2js e.g:

$ java -jar ../../Downloads/rhino1_7R4/js.jar myjs.js < in.txt > out.txt

I’m considering editing the dart2js generated file and adding something like:

scan = new BufferedReader( new InputStreamReader(System['in']) );


dart2js is for running in the browser.
dart:io will not convert to JS because the browser doesn’t support this functionality (like stdout/stdin).

Do you want to run JS generated from Dart running on the Server using Rhino?
Maybe you could integrate the Dart VM in your app and run Dart code without transpiling to JS.

Answered By – Günter Zöchbauer

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *