How i check existence of file and directory in ApplicationDocumentsDirectory before download it ?
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");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With