non_nullable_equals_parameter
The parameter type of '==' operators should be non-nullable.
Description
#The analyzer produces this diagnostic when an override of the operator ==
has a parameter whose type is nullable. The language spec makes it impossible for the argument of the method to be null
, and the parameter's type should reflect that.
Example
#The following code produces this diagnostic because the implementation of the operator ==
in C
:
dart
class C {
@override
bool operator ==(Object? other) => false;
}
Common fixes
#Make the parameter type be non-nullable:
dart
class C {
@override
bool operator ==(Object other) => false;
}
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-06-23. View source or report an issue.