From 5ccf14d349b6657094ed5aa05b655cf459f7e2fa Mon Sep 17 00:00:00 2001 From: Herbert Poul Date: Fri, 30 Aug 2019 18:01:15 +0200 Subject: [PATCH] added support for renaming fields, deleting fields. --- lib/src/kdbx_entry.dart | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/src/kdbx_entry.dart b/lib/src/kdbx_entry.dart index 153e320..94e53bc 100644 --- a/lib/src/kdbx_entry.dart +++ b/lib/src/kdbx_entry.dart @@ -117,14 +117,27 @@ class KdbxEntry extends KdbxObject { StringValue getString(KdbxKey key) => _strings[key]; void setString(KdbxKey key, StringValue value) { + assert(key != null); if (_strings[key] == value) { _logger.finest('Value did not change for $key'); return; } 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) { final value = _strings[key]; if (value is PlainValue) {