ChannelScheduledFileUploadRequest constructor Null safety

ChannelScheduledFileUploadRequest(
  1. {required String channelUrl,
  2. required ScheduledFileMessageParams params}
)

Implementation

ChannelScheduledFileUploadRequest({
  required String channelUrl,
  required ScheduledFileMessageParams params,
}) : super() {
  url = 'storage/file';
  final fileSize = params.uploadFile.file?.lengthSync() ?? 0;
  if (fileSize == 0 || params.reqId == null) {
    throw InvalidParameterError();
  }

  //upload size limit
  if (state.uploadSizeLimit < fileSize) {
    throw FileSizeLimitExceededError();
  }

  body = {
    'channel_url': channelUrl,
    'request_id': params.reqId,
    'file': params.uploadFile,
  };

  params.thumbnailSizes?.asMap().forEach((index, value) =>
      body['thumbnail${index + 1}'] =
          '${value.width.round()},${value.height.round()}');

  isMultipart = true;
}