saveToTempDirectory static method

Future<List<String>> saveToTempDirectory(
  1. List<String?> filePaths, {
  2. bool doShowLoader = true,
})

saveToTempDirectory() : can be used to save files to temp directory (with in app) so can accessed later and go through in no-affect with changes to original file

Implementation

static Future<List<String>> saveToTempDirectory(
  List<String?> filePaths, {
  bool doShowLoader = true,
}) async {
  List<String> tempFiles = [];

  if (doShowLoader) ShowUFULoader(msg: '${'preparing_files'.tr}...');

  for (var path in filePaths) {
    if (path != null) {
      try {
        final filePath = filterFilePath(path);
        final newPath = getUniqueFileName(getFileName(path));

        final file = File(filePath);
        await file.copy(newPath);
        tempFiles.add(newPath);
      } catch (e) {
        continue;
      }
    }
  }

  if (doShowLoader) Get.back();

  return tempFiles;
}