updatePointer method

void updatePointer(
  1. Offset globalPosition,
  2. Size widgetSize
)

Updates the normalized pointer position from a global coordinate and widget size.

globalPosition is the pointer's position in global coordinates (e.g., from a PointerEvent). widgetSize is the size of the widget receiving the pointer event.

The resulting pointerPosition is clamped to 0.0–1.0 on both axes.

Implementation

void updatePointer(Offset globalPosition, Size widgetSize) {
  if (widgetSize.isEmpty) return;
  _pointerPosition = Offset(
    (globalPosition.dx / widgetSize.width).clamp(0.0, 1.0),
    (globalPosition.dy / widgetSize.height).clamp(0.0, 1.0),
  );
}