pickPlatformAttachments function
Implementation
Future<List<PromptAttachment>> pickPlatformAttachments(
PromptAttachmentKind kind,
) async {
final result = await FilePicker.platform.pickFiles(
type: switch (kind) {
PromptAttachmentKind.file => FileType.any,
PromptAttachmentKind.image => FileType.image,
PromptAttachmentKind.audio => FileType.audio,
},
allowMultiple: true,
withData: true,
);
return [
for (final file in result?.files ?? <PlatformFile>[])
if (file.bytes != null)
PromptAttachment.fromBytes(
bytes: file.bytes!,
name: file.name,
mimeType:
PromptAttachment.fromPath(path: file.name).mimeType ??
'application/octet-stream',
),
];
}