Dart await keyword


I want to try the rpc package of Dart using the io sample (https://github.com/dart-lang/rpc)

I’m on the 64 bits version of Dart editor with the 1.9.1 sdk (cannot update more thans stable version)

This is my pubspec.yaml :

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

But when I try to copy the sample for launch my server :

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

void start() {
    _apiServer.addApi(new Synchro());
    HttpServer server = await HttpServer.bind(InternetAddress.ANY_IP_V4, 9090);

My EDI(SDK) don’t know the await keyword. (I import the dart:io dart:async and rpc package in my library file)

I’ve missed something? Thanks by advance for your responses. Have a nice day.


You need to mark the function as async in order to be able to use await

void start() async {

try at DartPad

Without async await is a valid identifier.

Answered By – Günter Zöchbauer

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

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