updateUserProfile static method
Implementation
static Future<TPUser?> updateUserProfile(
String? username,
String? profileImageUrl,
Map<String, dynamic>? metaData,
{
String? translationLanguage,
Function(int? errorCode, String? errorMessage)? errorCallback
}) async
{
if (!_isInitialized(errorCallback: errorCallback)) { return null; }
//if (!_checkAuthInfo(errorCallback: errorCallback)) { return null; }
Map<String, dynamic> body = Map.from({});
if (username != null) { body["username"] = username; }
if (profileImageUrl != null) { body["profileImageUrl"] = profileImageUrl; }
if (metaData != null) { body["data"] = metaData; }
final language = translationLanguage ?? "";
if(language.isNotEmpty){ body["translationTargetLanguage"] = language; }
try {
String url = "/users/update";
Map<String, dynamic> response = await HttpUtil.postJson(url, body);
Map<String, dynamic> user = response["user"];
_mUser = TPUser(user);
return _mUser;
} on TPException catch(e) {
Logger.log("$e");
if(errorCallback != null) { errorCallback(e.getCode(), e.getMessage()); }
} catch(e){
Logger.log("$e");
if(errorCallback != null) { errorCallback(-1, e.toString()); }
}
return null;
}