Dart equatable

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Person {
final String name;

const Person(this.name);

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Person &&
runtimeType == other.runtimeType &&
name == other.name;

@override
int get hashCode => name.hashCode;
}

https://pub.dev/packages/equatable

1
2
3
4
5
6
7
8
9
10
import 'package:equatable/equatable.dart';

class Person extends Equatable {
final String name;

Person(this.name);

@override
List<Object> get props => [name];
}
Share