render method
Renders the view to the terminal.
view is the string representation of the current UI state,
or a View object containing metadata.
Implementation
@override
void render(Object view) {
_metrics.beginFrame();
final String content = switch (view) {
String s => s,
View v => v.content,
_ => view.toString(),
};
// Frame rate limiting
if (_lastRenderTime != null) {
final elapsed = DateTime.now().difference(_lastRenderTime!);
if (elapsed < _options.frameTime) {
_metrics.endFrame(skipped: true);
return;
}
}
// Clear previous output
if (_hasRendered && _lastLineCount > 0) {
_clearPreviousLines(_lastLineCount);
}
// Hide cursor during render if configured
if (_options.hideCursor) {
terminal.hideCursor();
}
// Write the new view
final output = _options.ansiCompress ? compressAnsi(content) : content;
terminal.write(output);
if (!output.endsWith('\n')) {
terminal.writeln();
}
// Show cursor after render
if (_options.hideCursor) {
terminal.showCursor();
}
_lastLineCount = content.split('\n').length;
_lastRenderTime = DateTime.now();
_hasRendered = true;
_metrics.endFrame();
}