containsSync method

bool containsSync(
  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 bool.

For the async method, see contains().

Implementation

bool containsSync(FileSystemEntity entity, {bool recursive = false}) {
  final entities = listSync(recursive: recursive);
  return entities.any(
      (element) => FileSystemEntity.identicalSync(entity.path, element.path));
}