Node constructor
Node({})
Implementation
Node({
required this.type,
String? id,
this.parent,
Attributes attributes = const {},
Iterable<Node> children = const [],
}) : _children = LinkedList<Node>()
..addAll(
children.map(
(e) => e..unlink(),
),
), // unlink the given children to avoid the error of "node has already a parent"
_attributes = attributes,
id = id ?? nanoid(6) {
for (final child in children) {
child.parent = this;
}
}