getFileSystemEntities method

Future<List<FileSystemEntity>> getFileSystemEntities(
  1. Directory dir
)

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;
}