2015-04-03 120 views
2

我想用IO樣品(https://github.com/dart-lang/rpc飛鏢等待關鍵字

我在64位版本的飛鏢編輯與1.9.1 SDK的嘗試飛鏢的RPC包(不能更新更thans穩定版本)

這是我pubspec.yaml:

name: myDartRestServer 
version: 0.0.1 
description: A minimal command-line application. 
#author: <your name> <[email protected]> 
#homepage: https://www.example.com 
environment: 
    sdk: '1.9.1' 
dependencies: 
    rpc: any 
dev_dependencies: 
    unittest: any 

但是,當我嘗試了我的樣本服務器複製的啓動:

final ApiServer _apiServer = new ApiServer('/api/', prettyPrint: true); 

void start() { 
    _apiServer.addApi(new Synchro()); 
    HttpServer server = await HttpServer.bind(InternetAddress.ANY_IP_V4, 9090); 
    server.listen(_apiServer.httpRequestHandler); 
    _apiServer.enableDiscoveryApi("http://localhost:9090"); 
} 

我的EDI(SDK)不知道await關鍵字。 (我導入dart:io dart:async和rpc包在我的庫文件中)

我錯過了什麼嗎?感謝您提前回復。祝你今天愉快。

回答

6

您需要標記功能async爲了能夠使用await

void start() async { 
    .... 

嘗試在DartPad

沒有asyncawait是一個有效的標識符。

+0

我錯過了,對不起!非常感謝您的幫助。 – Electron 2015-04-03 08:38:54