Skip to content

Instantly share code, notes, and snippets.

@felangel
Created January 7, 2019 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felangel/c015b3988063be69de23ba150f318eed to your computer and use it in GitHub Desktop.
Save felangel/c015b3988063be69de23ba150f318eed to your computer and use it in GitHub Desktop.
[intro_equatable] Person override == and hashcode
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