Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dart : check if a directory exist

Tags:

flutter

dart

In Dart would like to check if a directory exist but without knowing a substring of this directory :

eg :

dir = preview/1552146038702.jpg.1--001--001.html.test.jpg

I tried :

io.Directory(await dir).exists().then((exist){

but in the dir I don't know 1--001--001.html

Any idea?

like image 890
Julien Avatar asked Dec 03 '22 18:12

Julien


2 Answers

This works for me, hope my answer help

final path = '/storage/emulated/0/Download';
final checkPathExistence = await Directory(path).exists();
like image 31
Wisnu Wijokangko Avatar answered Dec 06 '22 09:12

Wisnu Wijokangko


Directory.exists() provides this information

bool exists = await Directory(path).exists();

  • https://api.dartlang.org/stable/2.2.0/dart-io/FileSystemEntity/exists.html
  • https://api.dartlang.org/stable/2.2.0/dart-io/FileSystemEntity/existsSync.html
like image 87
Günter Zöchbauer Avatar answered Dec 06 '22 09:12

Günter Zöchbauer