From f474b08593b4a6fee766196720ab0e28086d86d4 Mon Sep 17 00:00:00 2001 From: Herbert Poul Date: Wed, 5 Feb 2020 16:33:01 +0100 Subject: [PATCH] make custom data private --- lib/src/kdbx_custom_data.dart | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/src/kdbx_custom_data.dart b/lib/src/kdbx_custom_data.dart index 4935c92..fe58f21 100644 --- a/lib/src/kdbx_custom_data.dart +++ b/lib/src/kdbx_custom_data.dart @@ -5,11 +5,11 @@ import 'package:kdbx/src/internal/extension_utils.dart'; class KdbxCustomData extends KdbxNode { KdbxCustomData.create() - : data = {}, + : _data = {}, super.create(TAG_NAME); KdbxCustomData.read(xml.XmlElement node) - : data = Map.fromEntries( + : _data = Map.fromEntries( node.findElements(KdbxXml.NODE_CUSTOM_DATA_ITEM).map((el) { final key = el.singleTextNode(KdbxXml.NODE_KEY); final value = el.singleTextNode(KdbxXml.NODE_VALUE); @@ -19,14 +19,22 @@ class KdbxCustomData extends KdbxNode { static const String TAG_NAME = 'CustomData'; - final Map data; + final Map _data; + + Iterable> get entries => _data.entries; + + String operator [](String key) => _data[key]; + void operator []=(String key, String value) { + _data[key] = value; + isDirty = true; + } @override xml.XmlElement toXml() { final el = super.toXml(); el.children.clear(); el.children.addAll( - data.entries + _data.entries .map((e) => XmlUtils.createNode(KdbxXml.NODE_CUSTOM_DATA_ITEM, [ XmlUtils.createTextNode(KdbxXml.NODE_KEY, e.key), XmlUtils.createTextNode(KdbxXml.NODE_VALUE, e.value),