Reputation: 176
Every example of async code I have tried in Dart, mostly from their site does not seem to work for me.
import 'dart:io';
main() async {
var socket = await Socket.connect('127.0.0.1', 4041);
print(socket.runtimeType);
socket.write('Hello, World!');
}
Example code from their cookbook
And it throws me
error: line 3 pos 1: unexpected token 'main'
main() async {
I think its looking for a return type for the function? But I can't find any kind of documentmentation where you can tell what it is looking for, thanks for the help!
Upvotes: 1
Views: 548
Reputation: 4013
Dart asynchrony support (async, await etc.) came in version 1.9. You need to update your SDK.
Presumably your update did not work. Try choco upgrade dart-sdk
. Or you may have to uninstall then re-install the latest version.
Upvotes: 3