getDocument method Null safety
- {required String cid}
Retreiving 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 res = await MotorFlutter.to.getDocument('QmXyZ123');
if (res == null) {
throw Exception('Failed to fetch document');
}
Next Steps
- Upload a document to IPFS with MotorFlutter.uploadDocument
Implementation
Future<GetDocumentResponse> getDocument({required String cid}) async {
final res = await MotorFlutterPlatform.instance.getDocument(GetDocumentRequest(
cid: cid,
));
if (res == null) {
throw UnmarshalException<GetDocumentResponse>();
}
return res;
}