Created
January 7, 2019 03:30
-
-
Save felangel/c015b3988063be69de23ba150f318eed to your computer and use it in GitHub Desktop.
[intro_equatable] Person override == and hashcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
final String name; | |
final int age; | |
const Person({this.name, this.age}); | |
@override | |
bool operator ==(Object other) => | |
identical(this, other) || | |
other is Person && | |
runtimeType == other.runtimeType && | |
name == other.name && | |
age == other.age; | |
@override | |
int get hashCode => name.hashCode ^ age.hashCode; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment