update method
Updates the component state in response to a message.
Returns the updated component (often this) and an optional command.
Implementation
@override
(WizardModel, Cmd?) update(Msg msg) {
// Handle cancel (Escape key)
if (msg is KeyMsg &&
keyMatches(msg.key, [
KeyBinding(
keys: ['esc'],
help: Help(key: 'esc', desc: 'cancel'),
),
])) {
return (this, Cmd.message(const WizardCancelledMsg()));
}
// Text input steps submit on Enter (the underlying TextInputModel is purely
// an editor; submission is handled at the parent level).
if (_currentModel is TextInputModel &&
msg is KeyMsg &&
msg.key.type == KeyType.enter) {
final nextCmd = _nextStep();
return (this, nextCmd);
}
// Check for step completion messages
if (_isStepCompleteMsg(msg)) {
final nextCmd = _nextStep();
return (this, nextCmd);
}
// Forward message to current step's model
if (_currentModel != null) {
final (newModel, cmd) = _currentModel!.update(msg);
_currentModel = newModel;
return (this, cmd);
}
return (this, null);
}