addDocument method Null safety

Future<bool> addDocument(
  1. String label,
  2. 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);
}