values property

Stream<FileSystemHandle> get values

Asynchronous iterator of FileSystemHandle as found in this directory when called.

Test for the type of an handle using FileSystemHandle.kind such as:

final filesOnly = await directory.values
  .where((handle) => handle.kind == FileSystemKind.file))
  .cast<FileSystemFileHandle>()
  .toList();
final directoriesOnly = directory.values
  .where((handle) => handle.kind == FileSystemKind.directory))
  .cast<FileSystemDirectoryHandle>()
  .toList();

Throws a NotFoundError if this requested directory could not be found at the time operation was processed.

Implementation

Stream<FileSystemHandle> get values {
  final iterator = callMethod(this, "values", []);

  return jsAsyncIterator<FileSystemHandle>(iterator).cast<FileSystemHandle>().handleError((error) {
    if (jsIsNativeError(error, "NotFoundError")) {
      throw NotFoundError();
    } else {
      throw error;
    }
  });
}