Skip to content

Commit e69ecaa

Browse files
authored
Fix examples in avoid_null_checks_in_equality_operators (dart-archive/linter#3907)
1 parent c62d8d9 commit e69ecaa

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/src/rules/avoid_null_checks_in_equality_operators.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,28 @@ const _desc = r"Don't check for null in custom == operators.";
1717
const _details = r'''
1818
**DON'T** check for null in custom == operators.
1919
20-
As null is a special type, no class can be equivalent to it. Thus, it is
21-
redundant to check whether the other instance is null.
20+
As null is a special value, no instance of any class (other than `Null`) can be
21+
equivalent to it. Thus, it is redundant to check whether the other instance is
22+
null.
2223
2324
**BAD:**
2425
```dart
2526
class Person {
26-
final String name;
27+
final String? name;
2728
2829
@override
29-
operator ==(other) =>
30+
operator ==(Object? other) =>
3031
other != null && other is Person && name == other.name;
3132
}
3233
```
3334
3435
**GOOD:**
3536
```dart
3637
class Person {
37-
final String name;
38+
final String? name;
3839
3940
@override
40-
operator ==(other) => other is Person && name == other.name;
41+
operator ==(Object? other) => other is Person && name == other.name;
4142
}
4243
```
4344

0 commit comments

Comments
 (0)