writeEntry method

Future<void> writeEntry(
  1. String key,
  2. String value, {
  3. required bool isSecure,
})

Writes keyvalue to either the standard or secure store.

Optimistically updates the in-memory cache before notifying listeners so the UI reflects the change with zero extra I/O.

Implementation

Future<void> writeEntry(
  String key,
  String value, {
  required bool isSecure,
}) async {
  assert(_initialized, 'Call init() before writing.');
  if (isSecure) {
    await _secure!.write(key, value);
    _secureEntries = Map.unmodifiable({..._secureEntries, key: value});
  } else {
    await _standard!.write(key, value);
    _standardEntries = Map.unmodifiable({..._standardEntries, key: value});
  }
  notifyListeners();
}