下载前如何检查ApplicationDocumentsDirectory中文件和目录的存在?
答案 0 :(得分:0)
import 'dart:io';
import 'package:path_provider/path_provider.dart';
String fileName = "file.jpg";
String dir = (await getApplicationDocumentsDirectory()).path;
String savePath = '$dir/$fileName';
//for a directory: await Directory(savePath).exists();
if (await File(savePath).exists()) {
print("File exists");
} else {
print("File don't exists");
}