Skip to content

Commit 79d5ae4

Browse files
authored
Recommend using runtimeType in hash_and_equals (dart-archive/linter#1943)
> Using `is` in `operator ==` is usually wrong as it makes the `==` operator asymmetric. #36004 (comment)
1 parent 5d8bdcb commit 79d5ae4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/src/rules/hash_and_equals.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ class Better {
3939
Better(this.value);
4040
4141
@override
42-
bool operator ==(Object other) => other is Better && other.value == value;
42+
bool operator ==(Object other) =>
43+
other is Better &&
44+
other.runtimeType == runtimeType &&
45+
other.value == value;
4346
4447
@override
4548
int get hashCode => value.hashCode;

0 commit comments

Comments
 (0)