renderChild method
Renders a single child component onto canvas.
Override this method (instead of renderTree) when you need to intercept
per-child rendering — for example, to accumulate draw calls for batching.
The default implementation propagates the parent's render contexts into
the child before delegating to the child's Component.renderTree, and
cleans them up afterwards.
Implementation
@protected
void renderChild(Canvas canvas, Component child) {
int? originalLength;
final hasContext = _renderContexts.isNotEmpty;
if (hasContext) {
originalLength = child._renderContexts.length;
child._renderContexts.addAll(_renderContexts);
}
child.renderTree(canvas);
if (hasContext) {
child._renderContexts.removeRange(
originalLength!,
child._renderContexts.length,
);
}
}