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: false,
);
if (result == null) return const <PromptAttachment>[];
return result.files
.where((file) => file.path != null && file.path!.isNotEmpty)
.map(
(file) => PromptAttachment.fromPath(
path: file.path!,
name: file.name,
size: file.size,
),
)
.toList();
}