handleMouseEvent method
Handles mouse movement, press, and release within this button's bounds.
Implementation
@override
void handleMouseEvent(MouseEvent event, int localX, int localY) {
final resolvedWidth = _lastWidth > 0 ? _lastWidth : (widget.width ?? 0);
final resolvedHeight = _lastHeight > 0 ? _lastHeight : (widget.height ?? 0);
if (resolvedWidth <= 0 || resolvedHeight <= 0) return;
final inBounds =
localX >= 0 &&
localX < resolvedWidth &&
localY >= 0 &&
localY < resolvedHeight;
switch (event.type) {
case MouseEventType.press when inBounds:
_handlePress(localX, localY);
case MouseEventType.release when _isPressed:
_handleRelease(localX, localY, inBounds);
case MouseEventType.move || MouseEventType.drag:
setState(() {
_isHovered = inBounds && !_isPressed;
});
default:
break;
}
}