render method
Recalculates layout and paints the widget tree to the internal buffer.
Implementation
@override
void render() {
if (_isDisposed) return;
final rootElement = _rootElement;
final buffer = _currentBuffer;
if (rootElement == null || buffer == null) return;
// Rebuild the element tree to consume any new state modifications.
_buildOwner?.buildScope();
buffer.clear();
// Render the rebuilt element tree on our double buffer canvas.
rootElement.layout(BoxConstraints.tight(Size(_width, _computedHeight)));
rootElement.paint(buffer, Offset.zero);
if (debugPaintHoverEnabled && _lastMousePosition != null) {
final hovered = _findHoveredElement(rootElement, _lastMousePosition);
if (hovered != null) {
_highlightHoveredElement(buffer, hovered);
}
}
if (mode == ExecutionMode.standalone) {
if (debugMouseCursorEnabled && _lastMousePosition != null) {
final pos = _lastMousePosition!;
final cursorStyle = Style(
foreground: const Color(0, 255, 255),
modifiers: Modifier.bold,
);
buffer.writeString(pos.x - 1, pos.y - 1, '⦿', cursorStyle);
}
}
onFramePainted?.call(buffer);
onNeedVisualUpdate?.call();
if (mode == ExecutionMode.standalone) {
final b = terminal.backend;
if (b is BufferedTerminalBackend) {
b.buffer = buffer;
}
final sb = StringBuffer();
_renderer?.render(buffer, sb);
if (sb.isNotEmpty) {
b.write(sb.toString());
}
}
}