Viewport class

A string-backed scrollable viewport powered by ViewportModel.

Use this when content already exists as rendered text and you want line wrapping, line numbers, key handling, and optional integrated scrollbar behavior.

Inheritance

Constructors

Viewport({required String content, int? width, int? height, int gutter = 0, bool softWrap = false, bool fillHeight = false, bool showLineNumbers = false, bool mouseWheelEnabled = true, int mouseWheelDelta = 3, int horizontalStep = 6, ViewportKeyMap? keyMap, Style? style, ViewportController? controller, bool showScrollbar = false, String scrollbarSeparator = ' ', ScrollbarChars scrollbarChars = const ScrollbarChars(), bool enableSelection = false, bool handleKeys = true, String? zoneId, Key? key})
Creates a viewport widget.

Properties

children List<Widget>
Child widgets that receive forwarded messages.
no setterinherited
content String
Source content rendered by the viewport.
final
controller ViewportController?
Optional external controller.
final
debugRenderObjectPassthrough bool
Whether this widget is intentionally transparent to render-object layouts.
no setterinherited
enableSelection bool
Whether text selection support is enabled.
final
fillHeight bool
Whether to pad output to the configured height.
final
focusable bool
Whether this widget can receive keyboard focus.
no setterinherited
gutter int
Gutter width before content.
final
handleKeys bool
Whether key messages are forwarded to the viewport model.
final
hashCode int
The hash code for this object.
no setterinherited
height int?
Optional explicit viewport height in rows.
final
horizontalStep int
Horizontal scroll amount for applicable keybindings.
final
id String
Unique identifier for this widget.
no setterinherited
key Key?
Key for preserving widget identity.
finalinherited
keyMap ViewportKeyMap?
Optional keybinding overrides.
final
mouseWheelDelta int
Rows to scroll per wheel tick.
final
mouseWheelEnabled bool
Whether mouse wheel messages should scroll content.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollbarChars ScrollbarChars
Characters used for scrollbar rendering.
final
scrollbarSeparator String
Separator inserted between content and scrollbar.
final
showLineNumbers bool
Whether to show line numbers.
final
showScrollbar bool
Whether to render an integrated scrollbar.
final
softWrap bool
Whether long lines should soft-wrap.
final
style Style?
Optional style overrides.
final
theme Theme
Access the current theme.
no setterinherited
width int?
Optional explicit viewport width in columns.
final
zoneId String?
Optional mouse zone id override.
final

Methods

buildCachedView<T>(T builder(), Object? cacheKey) → T
Returns a cached view if the cache key matches.
inherited
createState() State<StatefulWidget>
Creates the mutable State associated with this widget.
override
handleInit() Cmd?
Override this instead of init for widget-specific initialization.
inherited
handleIntercept(Msg msg) → (Widget, Cmd?)
Override this to handle messages before they reach children.
inherited
handleUpdate(Msg msg) → (Widget, Cmd?)
Override this to handle messages specific to this widget.
inherited
init() Cmd?
Called once when the widget is first mounted.
inherited
invalidateCachedView() → void
Clears any cached view for this widget.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
update(Msg msg) → (Model, Cmd?)
Handles messages by forwarding to children then calling handleUpdate.
inherited
view() Object
Renders the widget to a string or View.
inherited

Operators

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