listWithExists method

Future<Stream<FileSystemEntity>> listWithExists({
  1. bool recursive = false,
  2. bool followLinks = true,
})

A safer version of exists, but checks that the directory exists before listing it's contents

Returns same result as list in future.

Implementation

Future<Stream<FileSystemEntity>> listWithExists({
  bool recursive = false,
  bool followLinks = true,
}) async {
  if (!await exists()) return const Stream.empty();
  return list(
    recursive: recursive,
    followLinks: followLinks,
  );
}