non_ nullable_ equals_ parameter
Details about the 'non_nullable_equals_parameter' diagnostic produced by the Dart analyzer.
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;
}
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.