Dart recently added a support for async/await keywords: https://www.dartlang.org/articles/await-async/
I tried to run a simple code but Chrome Dev Editor does not recognise async keyword
import 'dart:async';
void main() async {
}
Am I doing something wrong (something to modify in the pubspec.yaml
?) or is it just that this feature is not supported yet on Chrome Dev Editor ?
Edit:
Ok, so for know it seem that async/await seems to be more an experimental feature:
https://www.dartlang.org/docs/dart-up-and-running/ch02.html#async-opt-in
To opt into asynchrony support in Dart Editor, go to Preferences , click Experimental , and select Enable Async Support .
In dart and dartanalyzer, use the --enable-async command-line flag:
dart --enable-async async_await.dart dartanalyzer --enable-async async_await.dart
Unfortunatly, it seems only to work for Dart Editor, not CDE.
Also, dart does not currently support the conversion into javascript without adding a package:
dependencies:
async_await:
git: https://github.com/dart-lang/async_await.git
transformers:
- async_await
So currently it's not supported.
Now there is an issue on this problem: https://github.com/dart-lang/chromedeveditor/issues/3822
Thank you for all your answer
Wait & see...
Did you import the async module?
From the page you linked:
The features described in this article are still under development. Not all the parts of the system necessarily comply with the spec. Early adopters may need to import
dart:async
for these features to work. Ultimately, Future should move to dart:core and be universally available.
我现在正在使用Chromebook(无法验证),但我相信您必须在设置的实验功能下启用它。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.