ScheduledFileMessageCreateParams.withFile constructor

ScheduledFileMessageCreateParams.withFile(
  1. File file,
  2. {required int scheduledAt,
  3. String? fileName,
  4. String? customType,
  5. String? data,
  6. MentionType mentionType = MentionType.users,
  7. List<MessageMetaArray>? metaArrays,
  8. AppleCriticalAlertOptions? appleCriticalAlertOptions,
  9. PushNotificationDeliveryOption pushNotificationDeliveryOption = PushNotificationDeliveryOption.normal}
)

withFile

Implementation

ScheduledFileMessageCreateParams.withFile(
  File file, {
  required this.scheduledAt,
  this.fileName,
  this.customType,
  this.data,
  this.mentionType = MentionType.users,
  this.metaArrays,
  this.appleCriticalAlertOptions,
  this.pushNotificationDeliveryOption = PushNotificationDeliveryOption.normal,
}) {
  if (kIsWeb) {
    sbLog.e(StackTrace.current,
        "`ScheduledFileMessageCreateParams.withFile()` is not supported for web.");
    throw SendbirdException(
        message:
            "`ScheduledFileMessageCreateParams.withFile()` is not supported for web.");
  }

  String? fileMimeType;
  if (lookupMimeType(file.path) == null) {
    switch (getFileExtension(file.path)) {
      case '.HEIC':
        fileMimeType = 'image/heic';
        break;
      case '.HEIF':
        fileMimeType = 'image/heif';
        break;
      default:
        sbLog.w(StackTrace.current, 'Unknown file mimeType');
        break;
    }
  } else {
    fileMimeType = lookupMimeType(file.path)!;
  }

  fileInfo = FileInfo.fromFile(
    fileName: fileName ?? 'file',
    file: file,
    mimeType: fileMimeType,
  );
}