deleteIfExists method

Future<FileSystemEntity> deleteIfExists({
  1. bool recursive = false,
})

Deletes the file if it exists. Returns the deleted file instance or this if the file did not exist.

Implementation

Future<FileSystemEntity> deleteIfExists({bool recursive = false}) async {
  if (await exists()) return await delete(recursive: recursive);
  return this;
}