update method
Updates the component state in response to a message.
Returns the updated component (often this) and an optional command.
Implementation
@override
(FilePickerModel, Cmd?) update(Msg msg) {
switch (msg) {
case FilePickerReadDirMsg():
if (msg.id != _id) return (this, null);
return _handleReadDir(msg);
case FilePickerErrorMsg():
if (msg.id != _id) return (this, null);
return (copyWith(errorMessage: msg.error), null);
case WindowSizeMsg():
if (_autoHeight) {
final newHeight = msg.height - 5; // marginBottom = 5
return (copyWith(height: newHeight, max: newHeight - 1), null);
}
return (copyWith(max: _height - 1), null);
case KeyMsg():
return _handleKeyMsg(msg);
default:
return (this, null);
}
}