undefined_identifier_await
Details about the 'undefined_identifier_await' diagnostic produced by the Dart analyzer.
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:
void f(p) { await p; }
Common fixes
#Add the keyword async to the function body:
void f(p) async { await p; }
除非另有说明,文档之所提及适用于 Dart 3.10.3 版本报告页面问题.