Browse Source

added support for renaming fields, deleting fields.

remove-cryptography-dependency
Herbert Poul 5 years ago
parent
commit
5ccf14d349
  1. 15
      lib/src/kdbx_entry.dart

15
lib/src/kdbx_entry.dart

@ -117,14 +117,27 @@ class KdbxEntry extends KdbxObject {
StringValue getString(KdbxKey key) => _strings[key]; StringValue getString(KdbxKey key) => _strings[key];
void setString(KdbxKey key, StringValue value) { void setString(KdbxKey key, StringValue value) {
assert(key != null);
if (_strings[key] == value) { if (_strings[key] == value) {
_logger.finest('Value did not change for $key'); _logger.finest('Value did not change for $key');
return; return;
} }
isDirty = true; isDirty = true;
_strings[key] = value; if (value == null) {
_strings.remove(key);
} else {
_strings[key] = value;
}
}
void renameKey(KdbxKey oldKey, KdbxKey newKey) {
final value = _strings[oldKey];
removeString(oldKey);
_strings[newKey] = value;
} }
void removeString(KdbxKey key) => setString(key, null);
String _plainValue(KdbxKey key) { String _plainValue(KdbxKey key) {
final value = _strings[key]; final value = _strings[key];
if (value is PlainValue) { if (value is PlainValue) {

Loading…
Cancel
Save