joinGroup static method
Future<Group?>
joinGroup(
- String guid,
- String groupType, {
- String password = '',
- required dynamic onSuccess(
- Group group
- required dynamic onError(
- CometChatException excep
Returns a Group object after joining the logged in user to specified group. In order to start participating in group conversations, you will have to join a group
guid
A unique identifier for a group that logged in user wants to join.
groupType
needs to be either of the below 3 values public, private, password.
password
Mandatory in case group type is password only.
method could throw PlatformException with error codes specifying the cause
Implementation
static Future<Group?> joinGroup(String guid, String groupType, {String password = '', required Function(Group group)? onSuccess, required Function(CometChatException excep)? onError}) async {
try {
final result = await channel.invokeMethod('joinGroup', {
'guid': guid,
'groupType': groupType,
'password': password,
});
final res = Group.fromMap(result);
if(onSuccess != null) onSuccess(res);
return res;
} on PlatformException catch (platformException) {
if(onError != null) onError(CometChatException(platformException.code, platformException.details, platformException.message));
} catch (e) {
debugPrint("Error: $e");
if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
}
return null;
}