5
main() async {
  print('Hello World');
  await getAsyncString().then((hello) => print(hello));
}

Future<String> getAsyncString() async {
  return 'Hello Async World';
}

This is my code example, index.dart. It is in my web folder.

I run webdev build to compile to js.

When I run dart web/index.dart in my web folder I get the expected output of

Hello World
Hello Async World

When I run node build/index.dart.js or index.js I only get

Hello World

Is the async code running and is this expected behavior?

The full output is too long to post.

Steps to reproduce:

touch testcompile.dart

add the code

dart2js -O2 -o index.js testcompile.dart

node index.js

John Franke
  • 1,444
  • 19
  • 23
  • If you can provide the generated Javascript code from your `index.dart.js`, it may be helpful to people attempting to answer the question. – Conspicuous Compiler Apr 06 '19 at 00:37
  • 1
    The output is too long to place in the question. It is relatively easy to replicate though. For anyone interested, install the dart sdk https://www.dartlang.org/tools/sdk `touch testcompile.dart`, add the code, `dart2js -O2 -o index.js testcompile.dart`, finally `node index.js` – John Franke Apr 08 '19 at 14:02

0 Answers0