createBucket method Null safety

Future<StorageResponse<String>> createBucket(
  1. String id,
  2. [BucketOptions bucketOptions = const BucketOptions(public: false)]

Creates a new Storage bucket

id A unique identifier for the bucket you are creating. bucketOptions A parameter to optionally make the bucket public.


Future<StorageResponse<String>> createBucket(
  String id, [
  BucketOptions bucketOptions = const BucketOptions(public: false),
]) async {
  try {
    final FetchOptions options = FetchOptions(headers: headers);
    final response = await
      {'id': id, 'name': id, 'public': bucketOptions.public},
      options: options,
    if (response.hasError) {
      return StorageResponse(error: response.error);
    } else {
      final bucketId =['name'] as String;
      return StorageResponse<String>(data: bucketId);
  } catch (e) {
    return StorageResponse(error: StorageError(e.toString()));