createChildElement method
Implementation
MeshElement createChildElement(String tagName, Map<String, dynamic> attributes, {String? id}) {
final childElementType = _ensureChildValid(tagName);
_validateElementAttributes(childElementType, attributes);
final elementData = <String, dynamic>{
"name": tagName,
"attributes": {"\$id": id ?? const Uuid().v4(), ...attributes},
"children": _defaultChildren(tagName),
};
doc.sendChanges({
"documentID": doc.id,
"changes": [
{
"nodeID": this.id,
"insertChildren": {
"children": [
{"element": elementData},
],
},
},
],
});
return getNodeByID(elementData["attributes"]["\$id"])!;
}