getProfile method
dynamic
getProfile()
Implementation
getProfile() async {
//if(await AppUtils.isNetConnected()) {
var jid = SessionManagement.getUserJID().checkNull();
mirrorFlyLog("jid", jid);
if (jid.isNotEmpty) {
mirrorFlyLog("jid.isNotEmpty", jid.isNotEmpty.toString());
loading.value = true;
Mirrorfly.getUserProfile(jid,await AppUtils.isNetConnected()).then((value) {
debugPrint("profile--> $value");
insertDefaultStatusToUser();
loading.value = false;
var data = profileDataFromJson(value);
if (data.status != null && data.status!) {
if (data.data != null) {
profileName.text = data.data!.name ?? Constants.emptyString;
if (data.data!.mobileNumber.checkNull().isNotEmpty) {
//if (from.value != Routes.login) {
validMobileNumber(data.data!.mobileNumber.checkNull()).then((valid) {
// if(valid) profileMobile.text = data.data!.mobileNumber.checkNull();
mobileEditAccess(!valid);
});
}else {
var userIdentifier = SessionManagement.getUserIdentifier();
debugPrint("userIdentifier : $userIdentifier");
validMobileNumber(userIdentifier).then((value) => mobileEditAccess(!value));
// mobileEditAccess(true);
}
profileEmail.text = data.data!.email ?? Constants.emptyString;
profileStatus.value = data.data!.status.checkNull().isNotEmpty ? data.data!.status.checkNull() : AppConstants.defaultStatus;
userImgUrl.value = data.data!.image ?? Constants.emptyString;//SessionManagement.getUserImage() ?? Constants.emptyString;
SessionManagement.setUserImage(Constants.emptyString);
// changed((from.value == Routes.login));
changed(false);
name(data.data!.name.toString());
nameOnImage(data.data!.name.toString());
var userProfileData = ProData(
email: profileEmail.text.toString(),
image: userImgUrl.value,
mobileNumber: data.data!.mobileNumber.checkNull(),
nickName: profileName.text,
name: profileName.text,
status: profileStatus.value);
SessionManagement.setCurrentUser(userProfileData);
update();
}
} else {
debugPrint("Unable to load Profile data");
toToast(AppConstants.unableConnectServer);
}
}).catchError((onError) {
loading.value = false;
toToast(AppConstants.unableConnectServer);
});
}
/* }else{
toToast(AppConstants.noInternetConnection);
Get.back();
}*/
}