update method
Updates the component state in response to a message.
Returns the updated component (often this) and an optional command.
Implementation
@override
(MultiProgressModel, Cmd?) update(Msg msg) {
if (msg is! ProgressFrameMsg) return (this, null);
final cmds = <Cmd>[];
final newBars = Map<String, ProgressModel>.from(bars);
var changed = false;
for (final entry in bars.entries) {
final (newBar, cmd) = entry.value.update(msg);
if (newBar != entry.value) {
newBars[entry.key] = newBar;
changed = true;
}
if (cmd != null) cmds.add(cmd);
}
if (!changed && cmds.isEmpty) return (this, null);
return (
MultiProgressModel(bars: newBars, width: width),
cmds.isEmpty ? null : Cmd.batch(cmds),
);
}