User profiles
Update your profile
Use NCEngine.user.updateMyUserProfile() to modify the current user's profile.
UserProfile properties
| Property | Type | Description |
|---|---|---|
| name | String | Nickname (max 32 characters) |
| portraitUri | String | Avatar URL (max 128 characters) |
| uniqueId | String | User app ID (read-only from SDK) |
| String | Email (max 128 characters) | |
| birthday | String | Birthday (max 32 characters) |
| gender | UserGender | Gender: unknown (0), male (1), female (2) |
| location | String | Location (max 32 characters) |
| role | int | Role (0–100) |
| level | int | Level (0–100) |
| userExtProfile | Map | Custom extension (max 10 keys) |
Dart
final profile = UserProfile(name: 'Tom', portraitUri: 'https://example.com/avatar.png');
await NCEngine.user.updateMyUserProfile(profile, (error) {
if (error == null) print('Profile updated');
});
Get user profiles (batch)
Query up to 20 users per call.
Dart
await NCEngine.user.getUserProfiles(['user1', 'user2'], (profiles, error) {
if (error == null && profiles != null) {
print('Profiles: $profiles');
}
});
Get current user profile
Dart
await NCEngine.user.getMyUserProfile((profile, error) {
if (error == null) print('My profile: $profile');
});
Manage profile visibility
| Enum | Description |
|---|---|
| notSet | Inherit App Key setting |
| invisible | Hidden from all (except name and avatar) |
| everyone | Visible to all |
| friendVisible | Visible to friends only |
Set visibility
Dart
await NCEngine.user.updateMyUserProfileVisibility(
UserProfileVisibility.everyone,
(error) {
if (error == null) print('Visibility updated');
},
);
Get visibility
Dart
await NCEngine.user.getMyUserProfileVisibility((int? visibility, NCError? error) {
if (error == null) print('Visibility: $visibility');
});
Search by user ID
info
Searching a public profile by uniqueId is not currently exposed in the Flutter SDK wrapper. Use getUserProfiles() when you already know the target user IDs.
Subscribe to profile changes
Use SubscribeType.userProfile to subscribe to user profile and visibility changes for up to 200 users (1000 total).
Dart
final params = SubscribeEventParams(
subscribeType: SubscribeType.userProfile,
expiry: 180000,
userIds: ['user1', 'user2'],
);
await NCEngine.user.subscribeEvent(params, (failedUserIds, error) {
if (error == null) print('Subscribed to profile updates');
});
Listen for profile changes
Dart
NCEngine.addUserHandler('profile-handler', UserHandler(
onSubscribeEvent: (subscribeEvents) {
print('Profile changes: $subscribeEvents');
},
onSubscriptionSyncCompleted: (type) {
print('Sync completed for type: $type');
},
));