考虑以下 Dart 源代码(Flutter 项目):
void foo() {
await bar();
}
Future<void> bar() async {
print("test");
}
这会导致 Android Studio 出现以下错误:
内置标识符 'await' 不能用作类型
。
如果我将其更改为 (await bar());
,则会收到错误消息 Unexpected text 'await'
。
我在这里错过了什么?
最佳答案
foo()
方法需要用async
标记。
Future<void> foo() async {
await bar();
}
关于android-studio - Android Studio 无法识别 Dart 关键字 'await',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53925932/