save method
Data stored in the model is stored in a database external to the app that is tied to the model.
The updated Resuult
can be obtained at the stage where the loading is finished.
Implementation
@override
Future<LocalDocumentModel<T>> save() async {
if (_completer != null) {
await future;
return this;
}
_completer = Completer<void>();
try {
await onSave();
final data = filterOnSave(toMap(value));
_query ??= _LocalStoreDocumentQuery(
path: path,
callback: _handledOnUpdate,
origin: this,
);
LocalDatabase._db.saveDocument(_query!, data);
notifyListeners();
await onDidSave();
_completer?.complete();
_completer = null;
} catch (e) {
_completer?.completeError(e);
_completer = null;
} finally {
_completer?.complete();
_completer = null;
}
return this;
}