initialize method
void
initialize(
)
override
Called after this Node is added to the Node tree.
Flowing downwards
Implementation
@override
void initialize() {
super.initialize();
final parentPaintedNodes = parentNodes.whereType<PaintedNode>();
if (parentPaintedNodes.isEmpty) {
html.document.body!.append(element);
} else {
final parentPaintedNode = parentPaintedNodes.first;
if (parentPaintedNode is SingleChildPaintedNode) {
parentPaintedNode.element.append(element);
} else if (parentPaintedNode is MultiChildPaintedNode) {
final thisWithParentNodes = [this, ...parentNodes];
final parentPaintedNodeChild =
thisWithParentNodes.indexOf(parentPaintedNodes.first) - 1;
final index = parentPaintedNode.childNodes
.indexOf(thisWithParentNodes[parentPaintedNodeChild]);
final parentElement = parentPaintedNode.element;
if (parentElement.children.length <= index) {
parentElement.append(element);
} else {
parentElement.insertBefore(element, parentElement.children[index]);
}
}
}
initializeElement();
_animation = widget.animation?.runOnElement(element);
}