ChannelFileMessageSendApiRequest constructor Null safety

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

Implementation

ChannelFileMessageSendApiRequest({
  required this.channelType,
  required String channelUrl,
  required FileMessageParams params,
  String? senderId,
  List<dynamic>? thumbnails,
  bool markAsRead = false,
  bool? requireAuth,
  List<String>? additionalMentionedUserIds,
}) : super() {
  url = '${channelType.urlString}/$channelUrl/messages';

  body = {
    'message_type': CommandString.fileMessage,
    'user_id': senderId ?? state.userId,
    'mark_as_read': markAsRead,
    'require_auth': requireAuth,
    'mentioned_user_ids': additionalMentionedUserIds,
    'thumbnails': thumbnails,
    'file_size': params.uploadFile.fileSize,
    'file_name': params.uploadFile.name,
    'file_type': params.uploadFile.mimeType,
    'url': params.uploadFile.url,
  };

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