Group information
Nexconn Chat UI uses Nexconn SDK group models directly and coordinates group pages through GroupProvider. The provider loads joined groups, group details, members, applications, followed members, invite candidates, and supported group operations.
Basic provider setup
GroupProvider requires an EngineProvider and uses the default Nexconn group APIs when no custom GroupOperations implementation is supplied.
final groupProvider = GroupProvider(
engineProvider: context.read<EngineProvider>(),
);
await groupProvider.loadJoinedGroups();
Use the exposed state to render your own UI or pass the provider to the built-in group pages.
Consumer<GroupProvider>(
builder: (context, provider, _) {
if (provider.isLoadingJoinedGroups) {
return const CircularProgressIndicator();
}
return ListView.builder(
itemCount: provider.joinedGroups.length,
itemBuilder: (context, index) {
final group = provider.joinedGroups[index];
return ListTile(
title: Text(provider.groupDisplayName(group)),
subtitle: Text(group.groupId ?? ''),
);
},
);
},
);
Load group details
Use loadGroupInfo and loadMembers when opening a group detail page.
final provider = context.read<GroupProvider>();
await Future.wait([
provider.loadGroupInfo(groupId),
provider.loadMembers(groupId),
provider.loadGroupFollows(groupId),
]);
final group = provider.groupInfo;
final members = provider.members;
groupDisplayName and memberDisplayName provide UI-safe fallbacks when names are missing.
Text(provider.groupDisplayName(group));
Text(provider.memberDisplayName(member));
Group profile updates
The default provider supports group profile editing when the underlying Nexconn SDK operation is available. Check the support flag before showing editing controls.
if (provider.supportsUpdateGroupProfile) {
final error = await provider.updateGroupProfile(
groupId,
const GroupProfileUpdate(
groupName: 'Product team',
avatarUrl: 'https://example.com/group.png',
notice: 'Weekly sync every Monday.',
introduction: 'Team discussion channel.',
),
);
if (error == null || error.isSuccess) {
await provider.loadGroupInfo(groupId);
}
}
Member management
GroupProvider wraps common member operations and returns NCError? for operation results.
await provider.inviteMembers(groupId, ['user_1', 'user_2']);
await provider.kickMembers(groupId, ['user_3']);
await provider.addAdmins(groupId, ['user_4']);
await provider.removeAdmins(groupId, ['user_4']);
await provider.transferOwner(groupId, 'new_owner_id');
Always inspect the returned NCError? before updating host-app state.
final error = await provider.inviteMembers(groupId, ['user_1']);
if (error != null && !error.isSuccess) {
showError(error.message ?? 'Invite failed');
return;
}
await provider.loadMembers(groupId);
The provider also exposes filtered helper lists for management screens.
final owners = provider.membersByRole(GroupMemberRole.owner);
final adminCandidates = provider.adminAddCandidates();
final removableMembers = provider.removableMembers();
Followed members
Followed members are useful for group notification and attention workflows. Load the current list, update it, and refresh after successful operations.
await provider.loadGroupFollows(groupId);
if (!provider.isGroupFollowedMember(userId)) {
final error = await provider.addGroupFollows(groupId, [userId]);
if (error == null || error.isSuccess) {
await provider.loadGroupFollows(groupId);
}
}
Custom group operations
If your app has an account service or approval workflow outside the default SDK calls, implement GroupOperations and inject it.
class AppGroupOperations implements GroupOperations {
bool get supportsUpdateGroupProfile => true;
bool get supportsLeaveGroup => true;
bool get supportsDismissGroup => false;
Future<GroupInfo?> getGroupInfo(String groupId) {
return appGroupService.getGroupInfo(groupId);
}
Future<List<GroupMemberInfo>> getGroupMembers(String groupId) {
return appGroupService.getMembers(groupId);
}
// Implement the remaining GroupOperations methods for your app.
}
final provider = GroupProvider(
engineProvider: context.read<EngineProvider>(),
operations: AppGroupOperations(),
);
Keep custom implementations consistent with Nexconn SDK models such as GroupInfo, GroupMemberInfo, GroupApplicationInfo, and FavoriteInfo. Do not create a parallel public group model unless the UI page needs data that is not represented by the SDK types.