fetch method Null safety

Future<GetDocumentResponse> fetch(
  1. {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

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;
}