Skip to content

Commit

Permalink
Recommend using runtimeType in hash_and_equals
Browse files Browse the repository at this point in the history
> Using `is` in `operator ==` is usually wrong as it makes the `==` operator asymmetric.
dart-lang/sdk#36004 (comment)
  • Loading branch information
micimize authored Jan 8, 2020
1 parent 015d9ea commit f8ccc3b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/src/rules/hash_and_equals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ class Better {
Better(this.value);
@override
bool operator ==(Object other) => other is Better && other.value == value;
bool operator ==(Object other) =>
other is Better &&
other.runtimeType == runtimeType &&
other.value == value;
@override
int get hashCode => value.hashCode;
Expand Down

0 comments on commit f8ccc3b

Please sign in to comment.