avoid_null_checks_in_equality_operators

Group: style

Maturity: stable

Dart SDK: >= 2.0.0 • (Linter v0.1.31)

View the Project on GitHub dart-lang/linter

DON'T check for null in custom == operators.

As null is a special type, no class can be equivalent to it. Thus, it is redundant to check whether the other instance is null.

BAD:

class Person {
  final String name;

  @override
  operator ==(other) =>
      other != null && other is Person && name == other.name;
}

GOOD:

class Person {
  final String name;

  @override
  operator ==(other) => other is Person && name == other.name;
}