fetch method Null safety
- {required String cid}
Fetching a Document
Fetches a document from IPFS using the provided cid
. Returns the SchemaDocument if successful, and null if the document was not found.
final bucket = await MotorFlutter.to.getBucket('did:snr:mXyZ123');
if (res == null) {
throw Exception('Failed to fetch document');
}
Next Steps
- Upload a document to IPFS with Bucket.add
Implementation
Future<GetDocumentResponse> fetch({required String cid}) async {
final res = await MotorFlutterPlatform.instance.getDocument(GetDocumentRequest(
cid: cid,
));
if (res == null) {
throw UnmarshalException<GetDocumentResponse>();
}
return res;
}