run method
T
run()
Runs the prompt and returns the result.
Returns initialValue if cancelled, otherwise returns the final value from the state.
Implementation
T run() {
final state = PromptState<T>(initialValue);
final bindings = buildBindings(state);
final frame = FrameView(
title: title,
theme: theme,
bindings: bindings,
);
void renderFrame(RenderOutput out) {
frame.render(out, (ctx) => render(ctx, state));
}
final runner = PromptRunner(hideCursor: hideCursor);
final result = runner.runWithBindings(
render: renderFrame,
bindings: bindings,
);
if (state.isCancelled || result == PromptResult.cancelled) {
return initialValue;
}
return state.value;
}