Attachment constructor

Attachment({
  1. String? id,
  2. String? type,
  3. String? titleLink,
  4. String? title,
  5. String? thumbUrl,
  6. String? text,
  7. String? pretext,
  8. String? ogScrapeUrl,
  9. String? imageUrl,
  10. String? footerIcon,
  11. String? footer,
  12. dynamic fields,
  13. String? fallback,
  14. String? color,
  15. String? authorName,
  16. String? authorLink,
  17. String? authorIcon,
  18. String? assetUrl,
  19. List<Action>? actions = const [],
  20. int? originalWidth,
  21. int? originalHeight,
  22. Map<String, Object?> extraData = const {},
  23. AttachmentFile? file,
  24. UploadState? uploadState,
})

Constructor used for json serialization

Implementation

Attachment({
  String? id,
  String? type,
  this.titleLink,
  String? title,
  this.thumbUrl,
  this.text,
  this.pretext,
  this.ogScrapeUrl,
  this.imageUrl,
  this.footerIcon,
  this.footer,
  this.fields,
  this.fallback,
  this.color,
  this.authorName,
  this.authorLink,
  this.authorIcon,
  this.assetUrl,
  this.actions = const [],
  this.originalWidth,
  this.originalHeight,
  Map<String, Object?> extraData = const {},
  this.file,
  UploadState? uploadState,
})  : id = id ?? const Uuid().v4(),
      _type = type,
      title = title ?? file?.name,
      _uploadState = uploadState,
      localUri = file?.path != null ? Uri.parse(file!.path!) : null,
      // For backwards compatibility,
      // set 'file_size', 'mime_type' in [extraData].
      extraData = {
        ...extraData,
        if (file?.size != null) 'file_size': file?.size,
        if (file?.mediaType != null) 'mime_type': file?.mediaType?.mimeType,
      };