delete static method

Future<void> delete(
  1. String fileUrl
)

Deletes a file from the server using its public URL.

fileUrl - The public URL of the file to delete.

Does nothing if the file does not exist or the URL is invalid.

Implementation

static Future<void> delete(String fileUrl) async {
  if (!fileUrl.startsWith(_baseUrl)) {
    return;
  }

  final filePath = fileUrl.replaceFirst(_baseUrl, _baseDir);
  final fileToDelete = File(filePath);

  if (await fileToDelete.exists()) {
    await fileToDelete.delete();
  }
}