equatable 0.1.9 equatable: ^0.1.9 copied to clipboard
An abstract class that helps to implement equality without needing to explicitly override == and hashCode.
import 'package:equatable/equatable.dart';
class Credentials extends Equatable {
final String username;
final String password;
Credentials({this.username, this.password}) : super([username, password]);
}
void main() {
final credentialsA = Credentials(username: 'Joe', password: 'password123');
final credentialsB = Credentials(username: 'Bob', password: 'password!');
final credentialsC = Credentials(username: 'Bob', password: 'password!');
print(credentialsA == credentialsA); // true
print(credentialsB == credentialsB); // true
print(credentialsA == credentialsB); // false
print(credentialsB == credentialsC); // true
print(credentialsA); // [Joe, password123]
print(credentialsB); // [Bob, password!]
print(credentialsC); // [Bob, password!]
}