代码之家  ›  专栏  ›  技术社区  ›  Telmo Marques

Android Studio中无法识别Dart关键字“wait”

  •  0
  • Telmo Marques  · 技术社区  · 6 年前

    void foo() {
      await bar();
    }
    
    Future<void> bar() async {
      print("test");
    }
    

    The built-in identifier 'await' can't be used as a type .

    如果我把它改成 (await bar()); Unexpected text 'await' .

    我错过了什么?

    The built-in identifier 'await' can't be used as a type Unexpected text 'await'

    1 回复  |  直到 6 年前
        1
  •  7
  •   chemamolins    6 年前

    这个 foo() 方法需要标记为 async .

    Future<void> foo() async {
      await bar();
    }