getUser static method
Future<User?>
getUser(
- String uid, {
- required dynamic onSuccess(
- User user
- required dynamic onError(
- CometChatException excep
Retrieve Particular User Details
uid : The UID of the user for whom the details are to be fetched
Migration Note: Migrated from platform channels to native Dart implementation. Behavior and signature remain identical for backward compatibility.
Android Reference: UsersRequest.fetchUser(String uid)
Implementation
static Future<User?> getUser(String uid,
{required Function(User user)? onSuccess,
required Function(CometChatException excep)? onError}) async {
try {
// Get SDK instance
final sdk = SdkRegistry.getInstance();
// Call native Dart user repository
final user = await sdk.users.getUser(uid);
// Call success callback
if (onSuccess != null) onSuccess(user);
return user;
} 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;
}