createProfile method
Future<void>
createProfile(
)
override
Implementation
@override
Future<void> createProfile() async {
AppConfig.logger.d("Profile to create ${_newProfile.name}");
if(_newProfile.photoUrl.isEmpty) {
_newProfile.photoUrl = user.photoUrl;
_newProfile.coverImgUrl = user.photoUrl;
} else {
_newProfile.coverImgUrl = _newProfile.photoUrl;
}
_newProfile.mainFeature = CoreUtilities.getProfileMainFeature(_newProfile);
_newProfile.isActive = true;
_newProfile.reviewStars = 0;
_newProfile.bannedGenres = [];
_newProfile.itemmates = [];
_newProfile.eventmates = [];
_newProfile.followers = [];
_newProfile.following = [];
_newProfile.unfollowing = [];
_newProfile.blockTo = [];
_newProfile.blockedBy = [];
_newProfile.posts = [];
_newProfile.hiddenPosts = [];
_newProfile.reports = [];
_newProfile.bands = [];
_newProfile.events = [];
_newProfile.reviews = [];
_newProfile.watchingEvents = [];
_newProfile.goingEvents = [];
_newProfile.playingEvents = [];
_newProfile.itemlists = {};
_newProfile.favoriteItems = [];
try {
String profileId = await ProfileFirestore().insert(user.id, _newProfile);
if(profileId.isNotEmpty) {
_newProfile.id = profileId;
user.profiles.add(_newProfile);
profile = _newProfile;
if(profileId.isNotEmpty) {
userFirestore.updateCurrentProfile(user.id, profileId);
AppConfig.logger.i("Additional profile created successfully.");
Get.offAllNamed(AppRouteConstants.home);
} else {
AppConfig.logger.e("Something wrong creating account.");
Get.offAllNamed(AppRouteConstants.login);
}
}
} catch (e) {
Get.snackbar(
CoreConstants.errorCreatingAccount.tr,
e.toString(),
snackPosition: SnackPosition.bottom,
);
AppConfig.logger.e("Something wrong creating account.");
Get.offAllNamed(AppRouteConstants.login);
update();
}
AppConfig.logger.d("Profile created: ${_newProfile.name} with id: ${_newProfile.id}");
AppHiveController().writeProfileInfo();
update();
}