TerminalSession class

Manages terminal session state (cursor visibility, raw mode).

This is a composable component that can be used:

  • Directly for display views that need cursor control
  • As part of PromptRunner for interactive prompts

For display views (no key input needed):

final session = TerminalSession(hideCursor: true);
final out = RenderOutput();

session.run(() {
  out.writeln('Loading...');
  // ... do work ...
  out.clear();
  out.writeln('Done!');
});

Constructors

TerminalSession({bool hideCursor = false, bool rawMode = false})

Properties

hashCode → int
The hash code for this object.
no setterinherited
hideCursor → bool
Whether to hide the cursor during the session.
final
isActive → bool
Whether the session is currently active.
no setter
rawMode → bool
Whether to enter raw terminal mode (for key input).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

end() → void
Ends the terminal session and restores state.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run<T>(T body()) → T
Runs body within this session, ensuring cleanup on exit.
runAsync<T>(FutureOr<T> body()) → Future<T>
Runs body within this session, ensuring cleanup after awaited work.
runWithOutput<T>(T body(RenderOutput out), {bool clearOnEnd = false}) → T
Runs body with a RenderOutput, clearing output at the end if requested.
runWithOutputAsync<T>(FutureOr<T> body(RenderOutput out), {bool clearOnEnd = false}) → Future<T>
Runs body with a RenderOutput, ensuring cleanup after awaited work.
start() → void
Starts the terminal session.
toString() → String
A string representation of this object.
inherited

Operators

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