Skip to content

Instantly share code, notes, and snippets.

@kasperpeulen
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save kasperpeulen/0f51d0ade8d83bc26cbf to your computer and use it in GitHub Desktop.

Select an option

Save kasperpeulen/0f51d0ade8d83bc26cbf to your computer and use it in GitHub Desktop.
Use the FilesSystemEntity delete()/deleteSync() method to delete a file, directory, or symlink. This method is inherited by File, Directory, and Link.
import 'dart:io';
main() async {
// Create a temporary directory.
Directory dir = Directory.systemTemp.createTempSync();
// Confirm it exists.
print(dir.existsSync());
// Delete the directory.
dir.deleteSync();
// Confirm it no longer exists.
print(dir.existsSync());
// async --------------------------------------------------------------------
// Create a temporary directory.
Directory asyncDir = await Directory.systemTemp.createTemp();
// Confirm it exists.
print(await dir.exists());
// Delete the directory.
await dir.delete();
// Confirm it no longer exists.
print(await dir.exists());
}
name: dart.io_FilesSystemEntity.delete_FilesSystemEntity.deleteSync
description: |
Use the FilesSystemEntity delete()/deleteSync() method to delete a file, directory,
or symlink. This method is inherited by File, Directory, and Link.
homepage: https://gist.github.com/kasperpeulen/0f51d0ade8d83bc26cbf
environment:
sdk: '>=1.11.0 <2.0.0'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment