invalid_extension_argument_count
Details about the 'invalid_extension_argument_count' diagnostic produced by the Dart analyzer.
Extension overrides must have exactly one argument: the value of 'this' in the extension method.
Description
#
The analyzer produces this diagnostic when an extension override doesn't
have exactly one argument. The argument is the expression used to compute
the value of this within the extension method, so there must be one
argument.
Examples
#The following code produces this diagnostic because there are no arguments:
extension E on String {
String join(String other) => '$this $other';
}
void f() {
E().join('b');
}
And, the following code produces this diagnostic because there's more than one argument:
extension E on String {
String join(String other) => '$this $other';
}
void f() {
E('a', 'b').join('c');
}
Common fixes
#Provide one argument for the extension override:
extension E on String {
String join(String other) => '$this $other';
}
void f() {
E('a').join('b');
}
除非另有说明,文档之所提及适用于 Dart 3.10.3 版本报告页面问题.