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:
dart
extension E on int {
void m() {}
}
f() {
E(3)..m();
}
Common fixes
#Use .
rather than ..
:
dart
extension E on int {
void m() {}
}
f() {
E(3).m();
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。