FrameView class

FrameView – Composable frame rendering for terminal views.

Eliminates the common boilerplate pattern found across views/prompts:

  • Create FramedLayout
  • Write top (with conditional bold)
  • Write content lines with LineBuilder
  • Write bottom border (conditionally)
  • Write hints from KeyBindings

Before FrameView:

void render(RenderOutput out) {
  final lb = LineBuilder(theme);
  final frame = FramedLayout(title, theme: theme);

  out.writeln(theme.boldTitles
    ? '${theme.bold}${frame.top()}${theme.reset}'
    : frame.top());

  // ... 10+ lines of content setup ...

  if (theme.showBorders) {
    out.writeln(frame.bottom());
  }

  out.writeln(bindings.toHintsBullets(theme));
}

After FrameView:

void render(RenderOutput out) {
  final wf = FrameView(title: title, theme: theme, bindings: bindings);
  wf.render(out, (ctx) {
    ctx.line('Content line');
    ctx.gutterLine('Indented content');
  });
}

Features:

  • Automatic themed frame (top/bottom borders)
  • FrameContext provides LineBuilder + convenience methods
  • Automatic hints from KeyBindings
  • Connector line support
  • Consistent styling across all views

Design principles:

  • Composition over inheritance
  • Separation of concerns (frame rendering vs view logic)
  • Backward compatible (use alongside existing patterns)
Available extensions

Constructors

FrameView({required String title, required PromptTheme theme, KeyBindings? bindings})
const

Properties

bindings KeyBindings?
Key bindings for hint generation.
final
features DisplayFeatures
Shorthand access to features.
no setter
glyphs TerminalGlyphs
Shorthand access to glyphs.
no setter
hashCode int
The hash code for this object.
no setterinherited
hintStyle HintStyle
Hint style from theme.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showConnector bool
Whether to show connector from theme.
no setter
theme PromptTheme
Theme for colors and styling.
final
title String
Title displayed in the frame header.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
render(RenderOutput out, void content(FrameContext ctx)) → void
Renders the complete frame with content.
renderContent(RenderOutput out, void content(FrameContext ctx)) → void
Renders without hints (for nested/partial renders).
show(void content(FrameContext ctx)) → void

Available on FrameView, provided by the FrameViewDisplayExtensions extension

Renders to stdout and returns immediately.
showContentTo(RenderOutput out, void content(FrameContext ctx)) → void

Available on FrameView, provided by the FrameViewDisplayExtensions extension

Renders content only (no frame borders) to a provided RenderOutput.
showTo(RenderOutput out, void content(FrameContext ctx)) → void

Available on FrameView, provided by the FrameViewDisplayExtensions extension

Renders to a provided RenderOutput without interaction.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited