contains method

Future<bool> contains(
  1. FileSystemEntity entity, {
  2. bool recursive = false,
})

Checks if this directory contains the entity.

The entity can be a File or a Directory. If recursive is true, it checks the subdirectories too.

Returns a Future<bool> holding the value.

For the sync method, see containsSync().

Implementation

Future<bool> contains(
  FileSystemEntity entity, {
  bool recursive = false,
}) async {
  final entities = list(recursive: recursive);
  return entities.any(
    (element) => FileSystemEntity.identicalSync(entity.path, element.path),
  );
}