dirContents function

Future<List<FileSystemEntity>> dirContents(
  1. Directory dir, {
  2. bool recursive = false,
})

Implementation

Future<List<FileSystemEntity>> dirContents(Directory dir,
    {bool recursive = false}) async {
  final files = <FileSystemEntity>[];
  final completer = Completer<List<FileSystemEntity>>();
  final lister = dir.list(recursive: recursive);
  lister.listen((file) {
    if (!isDSStore(file.path)) files.add(file);
  }, onDone: () => completer.complete(files));
  return completer.future;
}