deleteDirectory static method

Future<void> deleteDirectory(
  1. Directory dir
)

递归删除目录。

Implementation

static Future<void> deleteDirectory(Directory dir) async {
  final List<FileSystemEntity> entities = await dir.list().toList();
  for (final FileSystemEntity entity in entities) {
    if (entity is File) {
      await entity.delete();
    } else if (entity is Directory) {
      await deleteDirectory(entity);
    }
  }
  await dir.delete();
}