await_of_incompatible_type
The 'await' expression can't be used for an expression with an extension type that is not a subtype of 'Future'.
Description
#The analyzer produces this diagnostic when the type of the expression in an await
expression is an extension type, and the extension type isn't a subclass of Future
.
Example
#The following code produces this diagnostic because the extension type E
isn't a subclass of Future
:
extension type E(int i) {}
void f(E e) async {
await e;
}
Common fixes
#If the extension type is correctly defined, then remove the await
:
extension type E(int i) {}
void f(E e) {
e;
}
If the extension type is intended to be awaitable, then add Future
(or a subtype of Future
) to the implements
clause (adding an implements
clause if there isn't one already), and make the representation type match:
extension type E(Future<int> i) implements Future<int> {}
void f(E e) async {
await e;
}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.