sendUserMessage method Null safety

Future<UserMessage> sendUserMessage(
  1. {required ChannelType channelType,
  2. required String channelUrl,
  3. required UserMessageParams params,
  4. String? senderId,
  5. List<String>? additionalMentionedUserIds,
  6. bool markAsRead = false}
)

Implementation

Future<UserMessage> sendUserMessage({
  required ChannelType channelType,
  required String channelUrl,
  required UserMessageParams params,
  String? senderId,
  List<String>? additionalMentionedUserIds,
  bool markAsRead = false,
}) async {
  final url = endpoint.Channels.channelurl_messages.format([
    channelType.urlString,
    channelUrl,
  ]);
  final body = <String, dynamic>{
    'message_type': CommandType.userMessage,
    'user_id': senderId ?? currentUserId,
    'mark_as_read': markAsRead,
    if (additionalMentionedUserIds != null)
      'mentioned_user_ids': additionalMentionedUserIds,
  };

  body.addAll(params.toJson());
  body.removeWhere((key, value) => value == null);

  final res = await client.post(url: url, body: body);
  return BaseMessage.msgFromJson<UserMessage>(res,
      channelType: channelType)!; //mark!
}