Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit b50ce34

Browse files
authored
Recommend using runtimeType in hash_and_equals (#1943)
> Using `is` in `operator ==` is usually wrong as it makes the `==` operator asymmetric. dart-lang/sdk#36004 (comment)
1 parent 3deae6e commit b50ce34

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)