deleteFileDirectory static method

void deleteFileDirectory()

Deletes all files within the UpdateCenter directory for Android. This method is useful for cleaning up downloaded files.

Implementation

static void deleteFileDirectory() async {
  Directory updateDirectory = await directoryAndroid();

  if (await updateDirectory.exists()) {
    // List all files in the directory
    List<FileSystemEntity> files = updateDirectory.listSync();

    // Delete each file in the directory
    for (var file in files) {
      if (file is File) {
        await file.delete();
        log('Deleted file successfully: ${file.path}');
      }
    }
  }
}