pickTwoImageOrPdf static method
Implementation
static Future<List<Uint8List>> pickTwoImageOrPdf() async {
final result = await FilePicker.platform.pickFiles(
allowMultiple: true,
withData: true, // ensures bytes are filled on Web/desktop
type: FileType.custom,
allowedExtensions: ['jpg', 'jpeg', 'png', 'heic', 'webp', 'pdf'],
);
final files = <Uint8List>[];
if (result == null || result.files.length != 2)
return files; // keep same contract
for (final f in result.files) {
if (f.bytes != null) {
files.add(f.bytes!);
} else if (f.path != null) {
files.add(await File(f.path!).readAsBytes());
}
}
// If any read failed, ensure we still return [] unless we got both
return files.length == 2 ? files : <Uint8List>[];
}