getConversation static method

Future<Conversation?> getConversation(
  1. String conversationWith,
  2. String conversationType, {
  3. required dynamic onSuccess(
    1. Conversation conversation
    )?,
  4. required dynamic onError(
    1. CometChatException excep
    )?,
})

In order to fetch a specific conversation

conversationWith : UID/GUID of the user/group whose conversation you want to fetch.

conversationType : user or group.

The method could throw PlatformException with error codes specifying the cause

Implementation

static Future<Conversation?> getConversation(
    String conversationWith, String conversationType,
    {required Function(Conversation conversation)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  try {
    final result = await channel.invokeMethod('getConversation', {
      'conversationWith': conversationWith,
      'conversationType': conversationType,
    });
    final res = Conversation.fromMap(result);
    if (onSuccess != null) onSuccess(res);
    return res;
  } on PlatformException catch (p) {
    _errorCallbackHandler(null, p, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
  return null;
}