extension_override_with_cascade
Extension overrides have no value so they can't be used as the receiver of a cascade expression.
Description
#The analyzer produces this diagnostic when an extension override is used as the receiver of a cascade expression. The value of a cascade expression e..m
is the value of the receiver e
, but extension overrides aren't expressions and don't have a value.
Example
#The following code produces this diagnostic because E(3)
isn't an expression:
extension E on int {
void m() {}
}
f() {
E(3)..m();
}
Common fixes
#Use .
rather than ..
:
extension E on int {
void m() {}
}
f() {
E(3).m();
}
If there are multiple cascaded accesses, you'll need to duplicate the extension override for each one.
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.