undefined_identifier_await
Undefined name 'await' in function body not marked with 'async'.
Description
#The analyzer produces this diagnostic when the name await
is used in a
method or function body without being declared, and the body isn't marked
with the async
keyword. The name await
only introduces an await
expression in an asynchronous function.
Example
#The following code produces this diagnostic because the name await
is
used in the body of f
even though the body of f
isn't marked with the
async
keyword:
dart
void f(p) { await p; }
Common fixes
#Add the keyword async
to the function body:
dart
void f(p) async { await p; }
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。