deleteFile function

Future deleteFile(
  1. File file, {
  2. DeleteOptions? options,
})

Delete a directory recursively

Implementation

Future deleteFile(File file, {DeleteOptions? options}) async {
  options ??= defaultDeleteOptions;

  try {
    await file.delete(recursive: options.recursive);
  } catch (e) {
    if (e is FileSystemException) {
      if (e.status != FileSystemException.statusNotFound) {
        // ignore: avoid_print
        print('delete $file failed $e');
      }
    } else {
      // ignore: avoid_print
      print('delete $file failed $e');
    }
  }
  if (options.create) {
    await file.create(recursive: true);
  }
}