delete method

Future<bool> delete(
  1. String path, {
  2. required bool dryRun,
})

Implementation

Future<bool> delete(String path, {required bool dryRun}) async {
  if (isProtectedPath(path)) return false;
  if (!exists(path)) return false;
  if (dryRun) return true;

  final type = FileSystemEntity.typeSync(path, followLinks: false);
  try {
    if (type == FileSystemEntityType.directory) {
      await Directory(path).delete(recursive: true);
    } else {
      await File(path).delete();
    }
  } on FileSystemException {
    return false;
  }
  return true;
}