fromInterface static method
convert a ProfileInterface
to a Profile
Implementation
static Profile fromInterface(
ProfileInterface profileInterface,
) {
final loginSummary = profileInterface.loginSummary;
final emails = profileInterface.emails;
final profileCustomFieldsInterface = profileInterface.customFields;
final customFieldsInterface = profileCustomFieldsInterface != null
? Map<String?, Object?>.from(profileCustomFieldsInterface)
: null;
customFieldsInterface?.removeWhere((key, _) => key == null);
final customFields = customFieldsInterface?.cast<String, Object?>();
final profileConsentsInterface = profileInterface.consents;
final consentsInterface = profileConsentsInterface != null
? Map<String?, ConsentInterface?>.from(profileConsentsInterface)
: null;
consentsInterface
?.removeWhere((key, value) => key == null || value == null);
final consents = consentsInterface?.cast<String, ConsentInterface>().map(
(key, consentInterface) =>
MapEntry(key, ConsentConverter.fromInterface(consentInterface)),
);
return Profile(
uid: profileInterface.uid,
givenName: profileInterface.givenName,
middleName: profileInterface.middleName,
familyName: profileInterface.familyName,
name: profileInterface.name,
nickname: profileInterface.nickname,
birthdate: profileInterface.birthdate,
profileURL: profileInterface.profileURL,
picture: profileInterface.picture,
externalId: profileInterface.externalId,
authTypes: profileInterface.authTypes?.whereType<String>().toList(),
loginSummary: loginSummary != null
? LoginSummaryConverter.fromInterface(loginSummary)
: null,
username: profileInterface.username,
gender: profileInterface.gender,
email: profileInterface.email,
emailVerified: profileInterface.emailVerified,
emails: emails != null ? EmailsConverter.fromInterface(emails) : null,
phoneNumber: profileInterface.phoneNumber,
phoneNumberVerified: profileInterface.phoneNumberVerified,
addresses: profileInterface.addresses
?.whereType<ProfileAddressInterface>()
.map(ProfileAddressConverter.fromInterface)
.toList(),
locale: profileInterface.locale,
bio: profileInterface.bio,
customFields: customFields,
consents: consents,
createdAt: profileInterface.createdAt,
updatedAt: profileInterface.updatedAt,
liteOnly: profileInterface.liteOnly,
company: profileInterface.company,
);
}