update method
Updates the component state in response to a message.
Returns the updated component (often this) and an optional command.
Implementation
@override
(ViewportScrollPane, Cmd?) update(Msg msg) {
if (msg is MouseMsg) {
final local = _toLocal(msg);
final candidates = _localCandidates(local);
if (msg.button == MouseButton.left && _height > 0 && _maxOffset > 0) {
switch (msg.action) {
case MouseAction.press:
if (candidates.any(_isOnBar)) {
_dragging = true;
_scrollToCandidateY(candidates);
return (this, null);
}
break;
case MouseAction.release:
_dragging = false;
return (this, null);
case MouseAction.motion:
if (_dragging) {
_scrollToCandidateY(candidates);
return (this, null);
}
break;
default:
break;
}
}
// Fall through: let viewport handle clicks/selection, etc.
final (vp, cmd) = viewport.update(local);
viewport = vp;
return (this, cmd);
}
final (vp, cmd) = viewport.update(msg);
viewport = vp;
return (this, cmd);
}