addDocument method Null safety
- String label,
- SchemaDocument doc
Adds a SchemaDocument into the Bucket and returns bool
indicating success
Implementation
Future<bool> addDocument(String label, SchemaDocument doc) async {
if (!_isInitialized) {
await _resolve();
}
if (!doc.hasCid()) {
final newDoc = await doc.upload(label);
if (newDoc == null) {
return false;
}
doc = newDoc;
}
final item = BucketItem(
name: label,
type: ResourceIdentifier.CID,
schemaDid: doc.definition.did,
);
return await MotorFlutterPlatform.instance.addBucketObject(did, item);
}