update method
Updates the component state in response to a message.
Returns the updated component (often this) and an optional command.
Implementation
@override
(ConfirmModel, Cmd?) update(Msg msg) {
if (msg is KeyMsg) {
final key = msg.key;
if (keyMatches(key, [keyMap.cancel])) {
return (this, Cmd.message(const ConfirmCancelledMsg()));
}
if (keyMatches(key, [keyMap.yes])) {
_value = true;
return (this, Cmd.message(const ConfirmResultMsg(true)));
}
if (keyMatches(key, [keyMap.no])) {
_value = false;
return (this, Cmd.message(const ConfirmResultMsg(false)));
}
if (keyMatches(key, [keyMap.confirm])) {
return (this, Cmd.message(ConfirmResultMsg(_value)));
}
if (keyMatches(key, [keyMap.toggleLeft])) {
_value = true;
return (this, null);
}
if (keyMatches(key, [keyMap.toggleRight])) {
_value = false;
return (this, null);
}
}
return (this, null);
}