createBucket method Null safety
- String bucketName
Create a Bucket On-Chain
Takes a Bucket name as bucketName
and creates a new bucket on-chain. A succesful transaction will return a CreateBucketResponse.
final res = await MotorFlutter.to.createBucket(MsgCreateBucket(
name: 'my-bucket',
));
if (res == null) {
throw Exception('Failed to create bucket');
}
Next Steps
Implementation
Future<Bucket> createBucket(String bucketName) async {
final resp = await MotorFlutterPlatform.instance.createBucket(CreateBucketRequest(
creator: address.value,
label: bucketName,
visibility: BucketVisibility.PUBLIC,
role: BucketRole.USER,
));
if (resp == null) {
throw UnmarshalException<CreateBucketResponse>();
}
return Bucket.fromResponse(resp);
}