getBucket method Null safety

Future<StorageResponse<Bucket>> getBucket(
  1. String id

Retrieves the details of an existing Storage bucket.

id The unique identifier of the bucket you would like to retrieve.


Future<StorageResponse<Bucket>> getBucket(String id) async {
  try {
    final FetchOptions options = FetchOptions(headers: headers);
    final response = await fetch.get('$url/bucket/$id', options: options);
    if (response.hasError) {
      return StorageResponse(error: response.error);
    } else {
      return StorageResponse<Bucket>(data: Bucket.fromJson(;
  } catch (e) {
    return StorageResponse(error: StorageError(e.toString()));