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:
void f(p) { await p; }
Common fixes
#Add the keyword async
to the function body:
void f(p) async { await p; }
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.