ConfirmModel class

A confirmation (yes/no) component following the Model architecture.

Displays a prompt and allows the user to confirm or deny.

Example

final confirm = ConfirmModel(
  prompt: 'Delete this file?',
  defaultValue: false,
);

// In your update function:
switch (msg) {
  case ConfirmResultMsg(:final confirmed):
    if (confirmed) {
      deleteFile();
    }
    return (this, Cmd.quit());
  case ConfirmCancelledMsg():
    return (this, Cmd.quit());
}
Inheritance

Constructors

ConfirmModel({required String prompt, bool defaultValue = true, ConfirmDisplayMode displayMode = ConfirmDisplayMode.toggle, bool showHelp = false, ConfirmKeyMap? keyMap, ConfirmStyles? styles})
Creates a new confirm model.

Properties

defaultValue → bool
The default value (true = yes, false = no).
final
displayMode → ConfirmDisplayMode
How to display the options.
final
hashCode → int
The hash code for this object.
no setterinherited
keyMap → ConfirmKeyMap
Key bindings.
final
prompt → String
The prompt to display.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
showHelp → bool
Whether to show help text.
final
styles → ConfirmStyles
Styles.
final
value → bool
Gets the current selected value.
no setter

Methods

init() → Cmd?
Returns an optional command to execute on program startup.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setValue(bool value) → void
Sets the current value.
toggle() → void
Toggle the current value.
toString() → String
A string representation of this object.
inherited
update(Msg msg) → (ConfirmModel, Cmd?)
Updates the component state in response to a message.
override
view() → String
Renders the current model state for display.
override

Operators

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