getBucket method Null safety

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

Retrieves the details of an existing Storage bucket.

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

Implementation

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(response.data));
    }
  } catch (e) {
    return StorageResponse(error: StorageError(e.toString()));
  }
}