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:
dart
class C {
int operator +(a, b) => 0;
}
Common fixes
#Add or remove parameters to match the required number:
dart
class C {
int operator +(a) => 0;
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.