upload method
Uploads the SchemaDocument to the current accounts application-specific data store. The account then encrypts the data and effectively becomes the only entity to be able to view the values. A succesful transaction will return a UploadDocumentResponse.
final doc = defs.first.newDocument();
doc.set<String>('name', 'John Doe');
doc.set<int>('age', 42);
doc.set<bool>('isCool', true);
final res = await doc.save('My Profile');
if (res != null) {
print('Document saved successfully');
}
Implementation
Future<UploadDocumentResponse?> upload({String? creator}) 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;
}
final resp = await MotorFlutterPlatform.instance.uploadDocument(UploadDocumentRequest(
schemaDid: schemaDid,
label: label,
document: writeToJson().codeUnits,
));
if (resp == null) {
return null;
}
resp.document.cid = resp.cid;
return resp;
}