getConversationStarter static method

Future<void> getConversationStarter(
  1. String receiverId,
  2. String receiverType, {
  3. Map? configuration,
  4. required dynamic onSuccess(
    1. List<String> conversationStarters
    ),
  5. required dynamic onError(
    1. CometChatException e
    ),
})

Implementation

static Future<void> getConversationStarter(
    String receiverId, String receiverType,
    {Map? configuration,
    required Function(List<String> conversationStarters) onSuccess,
    required Function(CometChatException e) onError}) async {
  try {
    if (receiverId.isEmpty) {
      onError(CometChatException(
          ErrorCode.errorInvalidReceiverId,
          ErrorMessage.errorMessageInvalidReceiverId,
          ErrorMessage.errorMessageInvalidReceiverId));
    } else if (receiverType.isEmpty) {
      onError(CometChatException(
          ErrorCode.errorInvalidReceiverType,
          ErrorMessage.errorMessageInvalidReceiverType,
          ErrorMessage.errorMessageInvalidReceiverType));
    } else {
      final arguments = {
        "receiverId": receiverId,
        "receiverType": receiverType,
        "configuration": configuration
      };
      final result =
          await channel.invokeMethod('getConversationStarter', arguments);
      List<String> arrayOfStrings = List<String>.from(result);
      onSuccess(arrayOfStrings);
    }
  } on PlatformException catch (p) {
    _errorCallbackHandler(null, p, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
}