Skip to content

Modal

Category: UI

Source: modal.dart

Classes

ModalChoice

A choice in a confirmation modal.

Constructor

dart
const ModalChoice(this.label, this.hotkey)

Properties

PropertyTypeDescription
labelString
hotkeyString

ConfirmModal

An inline confirmation prompt rendered in the content flow.

Displays a highlighted title bar with context, followed by selectable choices. Navigate with ←/→ or press hotkeys directly.

Constructor

dart
ConfirmModal({
    required this.title,
    required this.bodyLines,
    required this.choices,
  })

Properties

PropertyTypeDescription
titleString
bodyLinesList<String>
choicesList<ModalChoice>
resultFuture<int> getThe future that resolves with the index of the chosen option.
isCompletebool getWhether the modal has been resolved.
selectedint getThe currently selected choice index.
resultFuture<int> getThe future that resolves with the index of the chosen option.
isCompletebool getWhether the modal has been resolved.
selectedint getThe currently selected choice index.

Methods

bool handleEvent(TerminalEvent event)

Handle a terminal event. Returns true if consumed.

void cancel()

Cancel the modal by completing with the "No"/deny choice.

List<String> render(int terminalWidth)

Render the modal as lines to be appended to the output.

Released under the MIT License.