undefined_operator
The operator '{0}' isn't defined for the type '{1}'.
Description
#The analyzer produces this diagnostic when a user-definable operator is invoked on an object for which the operator isn't defined.
Example
#The following code produces this diagnostic because the class C
doesn't define the operator +
:
dart
class C {}
C f(C c) => c + 2;
Common fixes
#If the operator should be defined for the class, then define it:
dart
class C {
C operator +(int i) => this;
}
C f(C c) => c + 2;
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.