deleteBucket method
Deletes an existing bucket. A bucket can't be deleted with existing objects inside it.
You must first emptyBucket()
the bucket.
id
The unique identifier of the bucket you would like to delete.
Implementation
Future<StorageResponse<String>> deleteBucket(String id) async {
try {
final FetchOptions options = FetchOptions(headers: headers);
final response =
await fetch.delete('$url/bucket/$id', {}, options: options);
if (response.hasError) {
return StorageResponse(error: response.error);
} else {
return StorageResponse<String>(
data: response.data['message'] as String,
);
}
} catch (e) {
return StorageResponse(error: StorageError(e.toString()));
}
}