saveMultipleFiles method
Future<List<String> >
saveMultipleFiles({
- required List<
Uint8List> dataList, - required List<
String> fileNameList, - required List<
String> mimeTypeList,
override
Saves multiple files using platform-specific implementation.
Returns a list of saved file paths (or identifiers) for each file. On iOS the paths are temporary staging locations; on Web they indicate that a browser download was triggered.
dataList: List of file data in bytes.
fileNameList: List of file names with extensions.
mimeTypeList: List of corresponding MIME types.
Implementation
@override
Future<List<String>> saveMultipleFiles({
required List<Uint8List> dataList,
required List<String> fileNameList,
required List<String> mimeTypeList,
}) async {
final downloadsDir = await getDownloadsDirectory();
if (downloadsDir == null) {
throw StateError('Could not locate the Downloads directory.');
}
final results = <String>[];
for (int i = 0; i < dataList.length; i++) {
final file = File(
'${downloadsDir.path}${Platform.pathSeparator}${fileNameList[i]}',
);
await file.writeAsBytes(dataList[i], flush: true);
results.add(file.path);
}
return results;
}