updateCurrentUserDetails static method
Future<User?>
updateCurrentUserDetails(
- User user, {
- required dynamic onSuccess(
- User retUser
- required dynamic onError(
- CometChatException excep
Updating a logged-in user is similar to updating a user
method could throw PlatformException with error codes specifying the cause
Migration Note: Migrated from platform channels to native Dart implementation. Behavior and signature remain identical for backward compatibility.
Android Reference: UsersRequest.updateCurrentUserDetails(User user)
Implementation
static Future<User?> updateCurrentUserDetails(User user,
{required Function(User retUser)? onSuccess,
required Function(CometChatException excep)? onError}) async {
try {
// Get SDK instance
final sdk = SdkRegistry.getInstance();
// Call native Dart user repository
final updatedUser = await sdk.users.updateMyDetails(user);
// Call success callback
if (onSuccess != null) onSuccess(updatedUser);
return updatedUser;
} on SdkException catch (sdkEx) {
// Convert SdkException to CometChatException
final cometChatEx = CometChatException(
sdkEx.code,
sdkEx.details ?? sdkEx.message,
sdkEx.message,
);
_errorCallbackHandler(cometChatEx, null, null, onError);
} catch (e) {
_errorCallbackHandler(null, null, e, onError);
}
return null;
}