The-Agency/lib/ui/models/attachment.dart

22 lines
553 B
Dart

import 'dart:typed_data';
class Attachment {
final String name;
final String mimeType;
final Uint8List data;
final DateTime createdAt;
Attachment({
required this.name,
required this.mimeType,
required this.data,
DateTime? createdAt,
}) : createdAt = createdAt ?? DateTime.now();
bool get isImage => mimeType.startsWith('image/');
bool get isPdf => mimeType == 'application/pdf';
bool get isText => mimeType.startsWith('text/');
int get sizeInKB => (data.length / 1024).ceil();
String get displayName => name;
}