feat(auth): add toString and equality on entities and models

This commit is contained in:
Hugo Pointcheval 2022-11-11 18:46:37 -05:00
parent 33ac5c6280
commit 08f789725b
Signed by: hugo
GPG Key ID: A9E8E9615379254F
4 changed files with 43 additions and 0 deletions

View File

@ -60,4 +60,28 @@ class AccountModel extends Account {
this.phoneNumber, this.phoneNumber,
this.photoURL, this.photoURL,
}); });
AccountModel copyWith({
String? uid,
String? email,
DateTime? creationTime,
bool? emailVerified,
bool? isAnonymous,
bool? isNewUser,
DateTime? lastSignInTime,
String? phoneNumber,
String? photoURL,
String? providerId,
}) => AccountModel(
uid: uid ?? this.uid,
email: email ?? this.email,
creationTime: creationTime ?? this.creationTime,
emailVerified: emailVerified ?? this.emailVerified,
isAnonymous: isAnonymous ?? this.isAnonymous,
isNewUser: isNewUser ?? this.isNewUser,
lastSignInTime: lastSignInTime ?? this.lastSignInTime,
phoneNumber: phoneNumber ?? this.phoneNumber,
photoURL: photoURL ?? this.photoURL,
providerId: providerId ?? this.providerId,
);
} }

View File

@ -1,3 +1,4 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
// Copyright (C) 2022 WYATT GROUP // Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details. // Please see the AUTHORS file for details.
// //
@ -24,4 +25,12 @@ class AccountWrapperModel<T> extends AccountWrapper<T> {
final T? data; final T? data;
AccountWrapperModel(this.account, this.data); AccountWrapperModel(this.account, this.data);
AccountWrapperModel<T> copyWith({
Account? account,
T? data,
}) => AccountWrapperModel<T>(
account ?? this.account,
data ?? this.data,
);
} }

View File

@ -73,4 +73,11 @@ abstract class Account extends Equatable implements Entity {
providerId, providerId,
isNewUser, isNewUser,
]; ];
@override
String toString() => 'AccountModel(uid: $uid, email: $email, '
'creationTime: $creationTime, emailVerified: $emailVerified, '
'isAnonymous: $isAnonymous, isNewUser: $isNewUser, lastSignInTime: '
'$lastSignInTime, phoneNumber: $phoneNumber, photoURL: $photoURL, '
'providerId: $providerId)';
} }

View File

@ -24,4 +24,7 @@ abstract class AccountWrapper<T> extends Equatable implements Entity {
@override @override
List<Object?> get props => [account, data]; List<Object?> get props => [account, data];
@override
String toString() => 'AccountWrapper($account, data: $data)';
} }