wrong_number_of_parameters_for_operator
Operator '-' should declare 0 or 1 parameter, but {0} found.
Operator '{0}' should declare exactly {1} parameters, but {2} found.
Description
#The analyzer produces this diagnostic when a declaration of an operator has the wrong number of parameters.
Example
#The following code produces this diagnostic because the operator +
must have a single parameter corresponding to the right operand:
class C {
int operator +(a, b) => 0;
}
Common fixes
#Add or remove parameters to match the required number:
class C {
int operator +(a) => 0;
}
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.