invalid_extension_argument_count
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');
}
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.