fetch method
Fetches the SchemaDocument from the current accounts application-specific data store using the provided cid
. The account then decrypts the data and
its values are returned as a SchemaDocument. A succesful transaction will return a SchemaDocument.
final cid = MotorFlutter.to.getCIDForDid('did:3:...');
final doc = await SchemaDocument.pull(cid);
if (doc != null) {
print('Document pulled successfully');
}
Implementation
Future<SchemaDocument?> fetch(String cid) async {
if (!MotorFlutter.isReady) {
Log.warn('MotorFlutter has not been initialized. Please call MotorFlutter.init() before using the SDK.');
return null;
}
if (!MotorFlutter.to.authorized.value) {
Log.warn('MotorFlutter is not authorized. User MotorFlutter.to.createAccount() or MotorFlutter.to.login() to authorize the SDK.');
return null;
}
try {
final resp = await MotorFlutterPlatform.instance.getDocument(GetDocumentRequest(
cid: cid,
));
if (resp == null) {
return null;
}
return resp.document;
} catch (e) {
Log.warn(e.toString());
return null;
}
}