selectAttachment function
Future<void>
selectAttachment( - dynamic lang,
- dynamic ref,
- dynamic attachmentType
)
Implementation
Future<void> selectAttachment(
L10n lang,
WidgetRef ref,
AttachmentType attachmentType,
) async {
try {
FilePickerResult? result = await pick(lang, attachmentType);
if (result != null && result.files.isNotEmpty) {
final file = result.files.first;
String fileSize = getHumanReadableFileSize(file.size);
final title = p.basenameWithoutExtension(file.name);
final fileExtension = p.extension(file.name);
final attachment = PinAttachment(
attachmentType: attachmentType,
title: title,
fileExtension: fileExtension,
path: file.path,
size: fileSize,
);
ref.read(createPinStateProvider.notifier).addAttachment(attachment);
}
} catch (e, s) {
debugPrint('Error => $e');
_log.severe('Failed to select attachment', e, s);
}
}