Answers for "dart list files in directory"

0

dart list files in directory

Future<List<FileSystemEntity>> dirContents(Directory dir) {
  var files = <FileSystemEntity>[];
  var completer = Completer<List<FileSystemEntity>>();
  var lister = dir.list(recursive: false);
  lister.listen ( 
      (file) => files.add(file),
      // should also register onError
      onDone:   () => completer.complete(files)
      );
  return completer.future;
}
Posted by: Guest on December-31-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language