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
:
class C {
@override
bool operator ==(Object? other) => false;
}
Common fixes
#Make the parameter type be non-nullable:
class C {
@override
bool operator ==(Object other) => false;
}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.0. Page last updated on 2025-08-07. View source or report an issue.