toJson method
Implementation
@override
Map<String, dynamic> toJson() {
Map<String, dynamic> properties = {};
properties["ID"] = _id;
properties["Title"] = _title;
properties["Extended"] = _extended;
properties["Expanded"] = getExpanded().toString();
if (_link != null) {
properties["Link"] = _link!.getName();
}
if (_linkColor != null) {
properties["LinkColor"] = colorToString(_linkColor!);
}
if (_linkColors.isNotEmpty) {
List<String> l = [];
for (Color c in _linkColors) {
l.add(colorToString(c));
}
properties["LinkColors"] = l;
}
if (_linkWidth != null) {
properties["LinkWidth"] = _linkWidth.toString();
}
if (_borderColors.isNotEmpty) {
List<String> l = [];
for (Color c in _borderColors) {
l.add(colorToString(c));
}
properties["BorderColors"] = l;
}
if (_hSpace != null) {
properties["HSpace"] = _hSpace.toString();
}
if (_vSpace != null) {
properties["VSpace"] = _vSpace.toString();
}
if (_backgroundColor != null) {
properties["BackgroundColor"] = colorToString(_backgroundColor!);
}
if (_border != null) {
properties["Border"] = {
"Top": {
"Color": colorToString(_border!.top.color),
"Width": _border!.top.width.toString(),
},
"Left": {
"Color": colorToString((_border as Border).left.color),
"Width": (_border as Border).right.width.toString(),
},
"Bottom": {
"Color": colorToString(_border!.bottom.color),
"Width": _border!.bottom.width.toString(),
},
"Right": {
"Color": colorToString((_border as Border).right.color),
"Width": (_border as Border).right.width.toString(),
},
};
}
if (_borderRadius != null) {
properties["BorderRadius"] = (_borderRadius as BorderRadius).bottomLeft.x
.toString();
}
if (_padding != null) {
properties["Padding"] = {
"Left": _padding!.left.toString(),
"Top": _padding!.top.toString(),
"Right": _padding!.right.toString(),
"Bottom": _padding!.bottom.toString(),
};
}
if (_textStyle != null) {
Color color = _textStyle!.color ?? Colors.black;
properties["TextStyle"] = {
"Color": colorToString(color),
"FontSize": (_textStyle!.fontSize ?? 16).toString(),
"Bold": _textStyle!.fontWeight == FontWeight.bold,
};
}
if (_linkInOffsetMode != null) {
properties["LinkInOffsetMode"] = _linkInOffsetMode!.name;
}
if (_linkOutOffsetMode != null) {
properties["LinkOutOffsetMode"] = _linkOutOffsetMode!.name;
}
List<Map<String, dynamic>> leftNodes = [];
for (IMindMapNode node in _leftItems) {
leftNodes.add(node.toJson());
}
List<Map<String, dynamic>> rightNodes = [];
for (IMindMapNode node in _rightItems) {
rightNodes.add(node.toJson());
}
Map<String, dynamic> json = {
"MindMapNode": {
"Nodes": {"Left": leftNodes, "Right": rightNodes},
"Properties": properties,
},
};
return json;
}