sendFileMessage method Null safety

Future<FileMessage> sendFileMessage(
  1. {required ChannelType channelType,
  2. required String channelUrl,
  3. required FileMessageParams params,
  4. String? senderId,
  5. List<Thumbnail>? thumbnails,
  6. bool markAsRead = false,
  7. bool requireAuth = false,
  8. List<String>? additionalMentionedUserIds}
)

Implementation

Future<FileMessage> sendFileMessage({
  required ChannelType channelType,
  required String channelUrl,
  required FileMessageParams params,
  String? senderId,
  List<Thumbnail>? thumbnails,
  bool markAsRead = false,
  bool requireAuth = false,
  List<String>? additionalMentionedUserIds,
}) async {
  final url = endpoint.Channels.channelurl_messages.format([
    channelType.urlString,
    channelUrl,
  ]);
  final body = <String, dynamic>{
    'message_type': CommandType.fileMessage,
    'user_id': senderId ?? currentUserId,
    'mark_as_read': markAsRead,
    'require_auth': requireAuth,
    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<FileMessage>(res,
      channelType: channelType)!; //mark!
}