Attachment constructor
Attachment({
- String? id,
- String? type,
- String? titleLink,
- String? title,
- String? thumbUrl,
- String? text,
- String? pretext,
- String? ogScrapeUrl,
- String? imageUrl,
- dynamic fields,
- String? fallback,
- String? color,
- String? authorName,
- String? authorLink,
- String? authorIcon,
- String? assetUrl,
- List<
Action> ? actions, - Map<
String, Object?> extraData = const {}, - AttachmentFile? file,
- UploadState? uploadState,
Constructor used for json serialization
Implementation
Attachment({
String? id,
this.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,
List<Action>? actions,
Map<String, Object?> extraData = const {},
this.file,
UploadState? uploadState,
}) : id = id ?? const Uuid().v4(),
title = title ?? file?.name,
localUri = file?.path != null ? Uri.parse(file!.path!) : null,
actions = actions ?? [],
// For backwards compatibility,
// set 'file_size', 'mime_type' in [extraData].
extraData = {
...extraData,
if (file?.size != null) 'file_size': file?.size,
if (file?.mimeType != null) 'mime_type': file?.mimeType?.mimeType,
} {
this.uploadState = uploadState ??
((assetUrl != null || imageUrl != null)
? const UploadState.success()
: const UploadState.preparing());
}