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.2. Page last updated on 2025-9-1. View source or report an issue.