PromptRunner<T> class
A helper class to run an interactive terminal prompt inline. It encapsulates the event loop, rendering to an inline buffer, and lifecycle management.
Example:
final name = await PromptRunner<String>(
terminal: terminal,
widget: Column([
const Text('Enter name:'),
TextField(controller: myController, focused: true),
]),
exitConditions: {
PromptExitTrigger.enter: PromptExitAction.complete,
PromptExitTrigger.escape: PromptExitAction.cancel,
},
onComplete: () => myController.text,
).run();
Constructors
-
PromptRunner({required Terminal terminal, required Widget widget, int? height, Map<
PromptExitTrigger, PromptExitAction> ? exitConditions, bool onKeyEvent(KeyEvent event)?, T onComplete()?}) - Creates a new PromptRunner.
Properties
-
exitConditions
→ Map<
PromptExitTrigger, PromptExitAction> -
Mapping of exit triggers to their corresponding actions.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → int?
-
The height constraint of the inline rendering block. If null, calculated dynamically.
final
- onComplete → T Function()?
-
An optional completion callback returning the final value of type
T.final - onKeyEvent → bool Function(KeyEvent event)?
-
An optional key event handler callback. Returns true if prompt is completed.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- terminal → Terminal
-
The active terminal instance.
final
- widget → Widget
-
The root widget configuration to display.
final
Methods
-
abort(
[Object? exception]) → void - Public programmatic abort.
-
dispose(
) → void - Public programmatic dispose/cleanup.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run(
) → Future< T?> - Starts the inline prompt loop and returns a Future containing the final result.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
defaultExitConditions
→ const Map<
PromptExitTrigger, PromptExitAction> - Default exit conditions mapping.