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) {
_initialize();
final String content = switch (view) {
String s => s,
View v => v.content,
_ => view.toString(),
};
if (_lastRenderTime != null) {
final elapsed = DateTime.now().difference(_lastRenderTime!);
// Only skip if the view hasn't changed; otherwise we must render or the
// terminal can get stuck with stale overlay content.
if (elapsed < _options.frameTime && content == _pendingView) {
return;
}
}
_pendingView = _composeView(content);
_dirty = true;
_lastRenderTime = DateTime.now();
// Unlike the other renderers, the UV renderer buffers terminal output in
// its own writer and needs a flush step to emit bytes. Do it immediately
// so Program doesn't need to coordinate flush ordering with control writes.
//
// Also schedule a terminal flush: Program doesn't call TuiRenderer.flush()
// today, and some terminals won't paint until the underlying sink is
// flushed.
_flushInternal();
unawaited(terminal.flush());
}