stashValue method
Implementation
Future<bool> stashValue(String key, dynamic value) async {
bool ok = true;
if (_stash == null) return ok;
try {
// key must be supplied
if (isNullOrEmpty(key)) return ok;
if (value == null) {
_stash!.map.remove(key);
_stash!.upsert();
Binding? binding = Binding.fromString('$key.value');
if (binding != null) {
_stash!.scope?.observables.remove(_stash!.scope?.getObservable(binding)?.key);
}
return ok;
}
// write application stash entry
_stash!.map[key] = value;
// save to the hive
await _stash!.upsert();
// set observable
_stash!.scope?.setObservable(key, value);
} catch (e) {
// stash failure always returns true
ok = true;
}
return ok;
}