getFileSystemEntities method
Implementation
Future<List<FileSystemEntity>> getFileSystemEntities(Directory dir) {
final files = <FileSystemEntity>[];
final completer = Completer<List<FileSystemEntity>>();
final filesStream = dir.list(recursive: true);
filesStream.listen((file) => files.add(file),
onError: (error) {
print(error);
exit(126);
},
onDone: () => completer.complete(files));
return completer.future;
}